@@ -629,7 +629,7 @@ unsigned int CppCheck::checkFile(const std::string& filename, const std::string
629629 mPlistFile .close ();
630630 }
631631
632- CheckUnusedFunctions checkUnusedFunctions ( nullptr , nullptr , nullptr ) ;
632+ CheckUnusedFunctions checkUnusedFunctions;
633633
634634 try {
635635 Preprocessor preprocessor (mSettings , this );
@@ -1069,39 +1069,39 @@ void CppCheck::checkNormalTokens(const Tokenizer &tokenizer)
10691069 const char * unusedFunctionOnly = std::getenv (" UNUSEDFUNCTION_ONLY" );
10701070 const bool doUnusedFunctionOnly = unusedFunctionOnly && (std::strcmp (unusedFunctionOnly, " 1" ) == 0 );
10711071
1072- const std::time_t maxTime = mSettings .checksMaxTime > 0 ? std::time (nullptr ) + mSettings .checksMaxTime : 0 ;
1072+ if (!doUnusedFunctionOnly) {
1073+ const std::time_t maxTime = mSettings .checksMaxTime > 0 ? std::time (nullptr ) + mSettings .checksMaxTime : 0 ;
10731074
1074- // call all "runChecks" in all registered Check classes
1075- // cppcheck-suppress shadowFunction - TODO: fix this
1076- for (Check *check : Check::instances ()) {
1077- if (Settings::terminated ())
1078- return ;
1079-
1080- if (maxTime > 0 && std::time (nullptr ) > maxTime) {
1081- if (mSettings .debugwarnings ) {
1082- ErrorMessage::FileLocation loc;
1083- loc.setfile (tokenizer.list .getFiles ()[0 ]);
1084- ErrorMessage errmsg ({std::move (loc)},
1085- emptyString,
1086- Severity::debug,
1087- " Checks maximum time exceeded" ,
1088- " checksMaxTime" ,
1089- Certainty::normal);
1090- reportErr (errmsg);
1075+ // call all "runChecks" in all registered Check classes
1076+ // cppcheck-suppress shadowFunction - TODO: fix this
1077+ for (Check *check : Check::instances ()) {
1078+ if (Settings::terminated ())
1079+ return ;
1080+
1081+ if (maxTime > 0 && std::time (nullptr ) > maxTime) {
1082+ if (mSettings .debugwarnings ) {
1083+ ErrorMessage::FileLocation loc;
1084+ loc.setfile (tokenizer.list .getFiles ()[0 ]);
1085+ ErrorMessage errmsg ({std::move (loc)},
1086+ emptyString,
1087+ Severity::debug,
1088+ " Checks maximum time exceeded" ,
1089+ " checksMaxTime" ,
1090+ Certainty::normal);
1091+ reportErr (errmsg);
1092+ }
1093+ return ;
10911094 }
1092- return ;
1093- }
10941095
1095- if (doUnusedFunctionOnly && dynamic_cast <CheckUnusedFunctions*>(check) == nullptr )
1096- continue ;
1097-
1098- Timer timerRunChecks (check->name () + " ::runChecks" , mSettings .showtime , &s_timerResults);
1099- check->runChecks (tokenizer, this );
1096+ Timer timerRunChecks (check->name () + " ::runChecks" , mSettings .showtime , &s_timerResults);
1097+ check->runChecks (tokenizer, this );
1098+ }
11001099 }
11011100
1102- if (mSettings .clang )
1101+ if (mSettings .clang ) {
11031102 // TODO: Use CTU for Clang analysis
11041103 return ;
1104+ }
11051105
11061106
11071107 if (mSettings .useSingleJob () || !mSettings .buildDir .empty ()) {
@@ -1116,18 +1116,17 @@ void CppCheck::checkNormalTokens(const Tokenizer &tokenizer)
11161116 delete fi1;
11171117 }
11181118
1119- // cppcheck-suppress shadowFunction - TODO: fix this
1120- for (const Check *check : Check::instances ()) {
1121- if (doUnusedFunctionOnly && dynamic_cast <const CheckUnusedFunctions*>(check) == nullptr )
1122- continue ;
1123-
1124- if (Check::FileInfo * const fi = check->getFileInfo (&tokenizer, &mSettings )) {
1125- if (!mSettings .buildDir .empty ())
1126- mAnalyzerInformation .setFileInfo (check->name (), fi->toString ());
1127- if (mSettings .useSingleJob ())
1128- mFileInfo .push_back (fi);
1129- else
1130- delete fi;
1119+ if (!doUnusedFunctionOnly) {
1120+ // cppcheck-suppress shadowFunction - TODO: fix this
1121+ for (const Check *check : Check::instances ()) {
1122+ if (Check::FileInfo * const fi = check->getFileInfo (&tokenizer, &mSettings )) {
1123+ if (!mSettings .buildDir .empty ())
1124+ mAnalyzerInformation .setFileInfo (check->name (), fi->toString ());
1125+ if (mSettings .useSingleJob ())
1126+ mFileInfo .push_back (fi);
1127+ else
1128+ delete fi;
1129+ }
11311130 }
11321131 }
11331132
@@ -1792,7 +1791,7 @@ void CppCheck::analyseWholeProgram(const std::string &buildDir, const std::list<
17921791 return ;
17931792 }
17941793 if (mSettings .checks .isEnabled (Checks::unusedFunction))
1795- CheckUnusedFunctions::analyseWholeProgram2 (mSettings , this , buildDir);
1794+ CheckUnusedFunctions::analyseWholeProgram (mSettings , this , buildDir);
17961795 std::list<Check::FileInfo*> fileInfoList;
17971796 CTU::FileInfo ctuFileInfo;
17981797
0 commit comments