| 1327 | //--------------------------------------------------------------------------- |
| 1328 | |
| 1329 | void 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); |
nothing calls this directly
no test coverage detected