cppcheck.cpp: only call `getFileInfo()` if necessary (#4510)
This commit is contained in:
parent
b9e07e918e
commit
10426f6707
|
@ -971,8 +971,10 @@ unsigned int CppCheck::checkFile(const std::string& filename, const std::string
|
||||||
mExitCode=1; // e.g. reflect a syntax error
|
mExitCode=1; // e.g. reflect a syntax error
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!mSettings.buildDir.empty()) {
|
||||||
mAnalyzerInformation.setFileInfo("CheckUnusedFunctions", checkUnusedFunctions.analyzerInfo());
|
mAnalyzerInformation.setFileInfo("CheckUnusedFunctions", checkUnusedFunctions.analyzerInfo());
|
||||||
mAnalyzerInformation.close();
|
mAnalyzerInformation.close();
|
||||||
|
}
|
||||||
|
|
||||||
// In jointSuppressionReport mode, unmatched suppressions are
|
// In jointSuppressionReport mode, unmatched suppressions are
|
||||||
// collected after all files are processed
|
// collected after all files are processed
|
||||||
|
@ -1039,21 +1041,28 @@ void CppCheck::checkNormalTokens(const Tokenizer &tokenizer)
|
||||||
// TODO: Use CTU for Clang analysis
|
// TODO: Use CTU for Clang analysis
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
||||||
|
if (mSettings.jobs == 1 || !mSettings.buildDir.empty()) {
|
||||||
// Analyse the tokens..
|
// Analyse the tokens..
|
||||||
|
|
||||||
CTU::FileInfo *fi1 = CTU::getFileInfo(&tokenizer);
|
CTU::FileInfo *fi1 = CTU::getFileInfo(&tokenizer);
|
||||||
if (fi1) {
|
if (fi1) {
|
||||||
|
if (mSettings.jobs == 1)
|
||||||
mFileInfo.push_back(fi1);
|
mFileInfo.push_back(fi1);
|
||||||
|
if (!mSettings.buildDir.empty())
|
||||||
mAnalyzerInformation.setFileInfo("ctu", fi1->toString());
|
mAnalyzerInformation.setFileInfo("ctu", fi1->toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const Check *check : Check::instances()) {
|
for (const Check *check: Check::instances()) {
|
||||||
Check::FileInfo *fi = check->getFileInfo(&tokenizer, &mSettings);
|
Check::FileInfo *fi = check->getFileInfo(&tokenizer, &mSettings);
|
||||||
if (fi != nullptr) {
|
if (fi != nullptr) {
|
||||||
|
if (mSettings.jobs == 1)
|
||||||
mFileInfo.push_back(fi);
|
mFileInfo.push_back(fi);
|
||||||
|
if (!mSettings.buildDir.empty())
|
||||||
mAnalyzerInformation.setFileInfo(check->name(), fi->toString());
|
mAnalyzerInformation.setFileInfo(check->name(), fi->toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
executeRules("normal", tokenizer);
|
executeRules("normal", tokenizer);
|
||||||
}
|
}
|
||||||
|
@ -1535,6 +1544,7 @@ void CppCheck::reportErr(const ErrorMessage &msg)
|
||||||
if (std::find(mErrorList.begin(), mErrorList.end(), errmsg) != mErrorList.end())
|
if (std::find(mErrorList.begin(), mErrorList.end(), errmsg) != mErrorList.end())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (!mSettings.buildDir.empty())
|
||||||
mAnalyzerInformation.reportErr(msg, mSettings.verbose);
|
mAnalyzerInformation.reportErr(msg, mSettings.verbose);
|
||||||
|
|
||||||
const Suppressions::ErrorMessage errorMessage = msg.toSuppressionsErrorMessage();
|
const Suppressions::ErrorMessage errorMessage = msg.toSuppressionsErrorMessage();
|
||||||
|
|
Loading…
Reference in New Issue