@@ -683,22 +683,32 @@ unsigned int CppCheck::checkFile(const FileWithDetails& file, const std::string
683
683
mAnalyzerInformation .reset (new AnalyzerInformation);
684
684
685
685
if (mUnusedFunctionsCheck && (mSettings .useSingleJob () || mAnalyzerInformation )) {
686
+ std::size_t hash = 0 ;
686
687
// this is not a real source file - we just want to tokenize it. treat it as C anyways as the language needs to be determined.
687
688
Tokenizer tokenizer (mSettings , *this );
688
689
// enforce the language since markup files are special and do not adhere to the enforced language
689
690
tokenizer.list .setLang (Standards::Language::C, true );
690
691
if (fileStream) {
691
- tokenizer.list .createTokens (*fileStream, file.spath ());
692
+ std::vector<std::string> files{file.spath ()};
693
+ simplecpp::TokenList tokens (*fileStream, files);
694
+ if (mAnalyzerInformation ) {
695
+ const Preprocessor preprocessor (mSettings , *this );
696
+ hash = calculateHash (preprocessor, tokens, mSettings );
697
+ }
698
+ tokenizer.list .createTokens (std::move (tokens));
692
699
}
693
700
else {
694
- std::ifstream in (file.spath ());
695
- tokenizer.list .createTokens (in, file.spath ());
701
+ std::vector<std::string> files{file.spath ()};
702
+ simplecpp::TokenList tokens (file.spath (), files);
703
+ if (mAnalyzerInformation ) {
704
+ const Preprocessor preprocessor (mSettings , *this );
705
+ hash = calculateHash (preprocessor, tokens, mSettings );
706
+ }
707
+ tokenizer.list .createTokens (std::move (tokens));
696
708
}
697
709
mUnusedFunctionsCheck ->parseTokens (tokenizer, mSettings );
698
710
699
711
if (mAnalyzerInformation ) {
700
- // TODO: how to get the proper tokenlist to generate the proper hash?
701
- const std::size_t hash = time (nullptr ); // calculateHash(tokenizer.list, mSettings);
702
712
std::list<ErrorMessage> errors;
703
713
mAnalyzerInformation ->analyzeFile (mSettings .buildDir , file.spath (), cfgname, hash, errors);
704
714
mAnalyzerInformation ->setFileInfo (" CheckUnusedFunctions" , mUnusedFunctionsCheck ->analyzerInfo ());
0 commit comments