@@ -676,21 +676,27 @@ unsigned int CppCheck::checkFile(const FileWithDetails& file, const std::string
676
676
try {
677
677
if (mSettings .library .markupFile (file.spath ())) {
678
678
if (mUnusedFunctionsCheck && (mSettings .useSingleJob () || !mSettings .buildDir .empty ())) {
679
+ std::size_t hash;
679
680
// 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.
680
681
Tokenizer tokenizer (mSettings , *this );
681
682
// enforce the language since markup files are special and do not adhere to the enforced language
682
683
tokenizer.list .setLang (Standards::Language::C, true );
683
684
if (fileStream) {
684
- tokenizer.list .createTokens (*fileStream, file.spath ());
685
+ std::vector<std::string> files{file.spath ()};
686
+ simplecpp::TokenList tokens (*fileStream, files);
687
+ const Preprocessor preprocessor (mSettings , *this );
688
+ hash = calculateHash (preprocessor, tokens, mSettings );
689
+ tokenizer.list .createTokens (std::move (tokens));
685
690
}
686
691
else {
687
- std::ifstream in (file.spath ());
688
- tokenizer.list .createTokens (in, file.spath ());
692
+ std::vector<std::string> files{file.spath ()};
693
+ simplecpp::TokenList tokens (file.spath (), files);
694
+ const Preprocessor preprocessor (mSettings , *this );
695
+ hash = calculateHash (preprocessor, tokens, mSettings );
696
+ tokenizer.list .createTokens (std::move (tokens));
689
697
}
690
698
mUnusedFunctionsCheck ->parseTokens (tokenizer, mSettings );
691
699
692
- // TODO: how to get the proper tokenlist to generate the proper hash?
693
- const std::size_t hash = time (nullptr ); // calculateHash(tokenizer.list, mSettings);
694
700
std::list<ErrorMessage> errors;
695
701
mAnalyzerInformation .analyzeFile (mSettings .buildDir , file.spath (), cfgname, hash, errors);
696
702
mAnalyzerInformation .setFileInfo (" CheckUnusedFunctions" , mUnusedFunctionsCheck ->analyzerInfo ());
0 commit comments