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