Skip to content

Commit

Permalink
CppCheck: calculate proper hash for markup file analyzer information …
Browse files Browse the repository at this point in the history
…[skip ci]
  • Loading branch information
firewave committed Dec 3, 2024
1 parent 7b31ad8 commit 5900421
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions lib/cppcheck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -680,21 +680,27 @@ unsigned int CppCheck::checkFile(const FileWithDetails& file, const std::string
try {
if (mSettings.library.markupFile(file.spath())) {
if (mUnusedFunctionsCheck && (mSettings.useSingleJob() || !mSettings.buildDir.empty())) {
std::size_t hash;
// 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.
Tokenizer tokenizer(mSettings, *this);
// enforce the language since markup files are special and do not adhere to the enforced language
tokenizer.list.setLang(Standards::Language::C, true);
if (fileStream) {
tokenizer.list.createTokens(*fileStream, file.spath());
std::vector<std::string> files{file.spath()};
simplecpp::TokenList tokens(*fileStream, files);
const Preprocessor preprocessor(mSettings, *this);
hash = calculateHash(preprocessor, tokens, mSettings);
tokenizer.list.createTokens(std::move(tokens));
}
else {
std::ifstream in(file.spath());
tokenizer.list.createTokens(in, file.spath());
std::vector<std::string> files{file.spath()};
simplecpp::TokenList tokens(file.spath(), files);
const Preprocessor preprocessor(mSettings, *this);
hash = calculateHash(preprocessor, tokens, mSettings);
tokenizer.list.createTokens(std::move(tokens));
}
mUnusedFunctionsCheck->parseTokens(tokenizer, mSettings);

// TODO: how to get the proper tokenlist to generate the proper hash?
const std::size_t hash = time(nullptr); // calculateHash(tokenizer.list, mSettings);
std::list<ErrorMessage> errors;
mAnalyzerInformation.analyzeFile(mSettings.buildDir, file.spath(), cfgname, hash, errors);
mAnalyzerInformation.setFileInfo("CheckUnusedFunctions", mUnusedFunctionsCheck->analyzerInfo());
Expand Down

0 comments on commit 5900421

Please sign in to comment.