MCPcopy Create free account
hub / github.com/cppcheck-opensource/cppcheck / checkNormalTokens

Method checkNormalTokens

lib/cppcheck.cpp:1329–1412  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1327//---------------------------------------------------------------------------
1328
1329void CppCheck::checkNormalTokens(const Tokenizer &tokenizer, AnalyzerInformation* analyzerInformation, const std::string& currentConfig)
1330{
1331 const ProgressReporter progressReporter(mErrorLogger, mSettings.reportProgress, tokenizer.list.getSourceFilePath(), "Run checkers");
1332
1333 CheckUnusedFunctions unusedFunctionsChecker;
1334
1335 // TODO: this should actually be the behavior if only "--enable=unusedFunction" is specified - see #10648
1336 // TODO: log message when this is active?
1337 const bool doUnusedFunctionOnly = Settings::unusedFunctionOnly();
1338
1339 if (!doUnusedFunctionOnly) {
1340 const std::time_t maxTime = mSettings.checksMaxTime > 0 ? std::time(nullptr) + mSettings.checksMaxTime : 0;
1341
1342 // call all "runChecks" in all registered Check classes
1343 for (Check * const c : CheckInstances::get()) {
1344 if (Settings::terminated())
1345 return;
1346
1347 if (maxTime > 0 && std::time(nullptr) > maxTime) {
1348 if (mSettings.debugwarnings) {
1349 ErrorMessage::FileLocation loc(tokenizer.list.getFiles()[0], 0, 0);
1350 ErrorMessage errmsg({std::move(loc)},
1351 "",
1352 Severity::debug,
1353 "Checks maximum time exceeded",
1354 "checksMaxTime",
1355 Certainty::normal);
1356 mErrorLogger.reportErr(errmsg);
1357 }
1358 return;
1359 }
1360
1361 Timer::run(c->name() + "::runChecks", mTimerResults, [&]() {
1362 c->runChecks(tokenizer, mErrorLogger);
1363 });
1364 }
1365 }
1366
1367 if (mSettings.checks.isEnabled(Checks::unusedFunction) && !mSettings.buildDir.empty()) {
1368 unusedFunctionsChecker.parseTokens(tokenizer, mSettings);
1369 }
1370 if (mUnusedFunctionsCheck && mSettings.useSingleJob() && mSettings.buildDir.empty()) {
1371 mUnusedFunctionsCheck->parseTokens(tokenizer, mSettings);
1372 }
1373
1374 if (mSettings.clang) {
1375 // TODO: Use CTU for Clang analysis
1376 return;
1377 }
1378
1379 if (mSettings.useSingleJob() || analyzerInformation) {
1380 // Analyse the tokens..
1381 {
1382 const CTU::FileInfo * const fi1 = CTU::getFileInfo(tokenizer);
1383 if (analyzerInformation)
1384 analyzerInformation->setFileInfo("ctu", fi1->toString());
1385 if (mSettings.useSingleJob())
1386 mFileInfo.push_back(fi1);

Callers

nothing calls this directly

Calls 15

terminatedFunction · 0.85
getFileInfoFunction · 0.85
parseTokensMethod · 0.80
setFileInfoMethod · 0.80
analyzerInfoMethod · 0.80
getFunction · 0.70
runFunction · 0.70
reportErrMethod · 0.45
nameMethod · 0.45
runChecksMethod · 0.45
isEnabledMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected