Skip to content

Commit d0a02bb

Browse files
authored
CppCheck: no need to preprocess markup files as they are not actual source code (#5896)
It should not be necessary to preprocess markup files. We only need to tokenize them so function calls can be marked as used.
1 parent e5d7376 commit d0a02bb

1 file changed

Lines changed: 12 additions & 7 deletions

File tree

lib/cppcheck.cpp

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -632,6 +632,18 @@ unsigned int CppCheck::checkFile(const std::string& filename, const std::string
632632
CheckUnusedFunctions checkUnusedFunctions(nullptr, nullptr, nullptr);
633633

634634
try {
635+
if (mSettings.library.markupFile(filename)) {
636+
Tokenizer tokenizer(mSettings, this);
637+
if (fileStream)
638+
tokenizer.list.createTokens(*fileStream, filename);
639+
else {
640+
std::ifstream in(filename);
641+
tokenizer.list.createTokens(in, filename);
642+
}
643+
checkUnusedFunctions.getFileInfo(&tokenizer, &mSettings);
644+
return EXIT_SUCCESS;
645+
}
646+
635647
Preprocessor preprocessor(mSettings, this);
636648
std::set<std::string> configurations;
637649

@@ -662,13 +674,6 @@ unsigned int CppCheck::checkFile(const std::string& filename, const std::string
662674
return mExitCode;
663675
}
664676

665-
if (mSettings.library.markupFile(filename)) {
666-
Tokenizer tokenizer(mSettings, this, &preprocessor);
667-
tokenizer.createTokens(std::move(tokens1));
668-
checkUnusedFunctions.getFileInfo(&tokenizer, &mSettings);
669-
return EXIT_SUCCESS;
670-
}
671-
672677
if (!preprocessor.loadFiles(tokens1, files))
673678
return mExitCode;
674679

0 commit comments

Comments
 (0)