@@ -631,7 +631,7 @@ unsigned int CppCheck::checkFile(const std::string& filename, const std::string
631631 mPlistFile .close ();
632632 }
633633
634- CheckUnusedFunctions checkUnusedFunctions ( nullptr , nullptr , nullptr ) ;
634+ CheckUnusedFunctions checkUnusedFunctions;
635635
636636 try {
637637 if (mSettings .library .markupFile (filename)) {
@@ -1076,39 +1076,39 @@ void CppCheck::checkNormalTokens(const Tokenizer &tokenizer)
10761076 const char * unusedFunctionOnly = std::getenv (" UNUSEDFUNCTION_ONLY" );
10771077 const bool doUnusedFunctionOnly = unusedFunctionOnly && (std::strcmp (unusedFunctionOnly, " 1" ) == 0 );
10781078
1079- const std::time_t maxTime = mSettings .checksMaxTime > 0 ? std::time (nullptr ) + mSettings .checksMaxTime : 0 ;
1079+ if (!doUnusedFunctionOnly) {
1080+ const std::time_t maxTime = mSettings .checksMaxTime > 0 ? std::time (nullptr ) + mSettings .checksMaxTime : 0 ;
10801081
1081- // call all "runChecks" in all registered Check classes
1082- // cppcheck-suppress shadowFunction - TODO: fix this
1083- for (Check *check : Check::instances ()) {
1084- if (Settings::terminated ())
1085- return ;
1086-
1087- if (maxTime > 0 && std::time (nullptr ) > maxTime) {
1088- if (mSettings .debugwarnings ) {
1089- ErrorMessage::FileLocation loc;
1090- loc.setfile (tokenizer.list .getFiles ()[0 ]);
1091- ErrorMessage errmsg ({std::move (loc)},
1092- emptyString,
1093- Severity::debug,
1094- " Checks maximum time exceeded" ,
1095- " checksMaxTime" ,
1096- Certainty::normal);
1097- reportErr (errmsg);
1082+ // call all "runChecks" in all registered Check classes
1083+ // cppcheck-suppress shadowFunction - TODO: fix this
1084+ for (Check *check : Check::instances ()) {
1085+ if (Settings::terminated ())
1086+ return ;
1087+
1088+ if (maxTime > 0 && std::time (nullptr ) > maxTime) {
1089+ if (mSettings .debugwarnings ) {
1090+ ErrorMessage::FileLocation loc;
1091+ loc.setfile (tokenizer.list .getFiles ()[0 ]);
1092+ ErrorMessage errmsg ({std::move (loc)},
1093+ emptyString,
1094+ Severity::debug,
1095+ " Checks maximum time exceeded" ,
1096+ " checksMaxTime" ,
1097+ Certainty::normal);
1098+ reportErr (errmsg);
1099+ }
1100+ return ;
10981101 }
1099- return ;
1100- }
11011102
1102- if (doUnusedFunctionOnly && dynamic_cast <CheckUnusedFunctions*>(check) == nullptr )
1103- continue ;
1104-
1105- Timer timerRunChecks (check->name () + " ::runChecks" , mSettings .showtime , &s_timerResults);
1106- check->runChecks (tokenizer, this );
1103+ Timer timerRunChecks (check->name () + " ::runChecks" , mSettings .showtime , &s_timerResults);
1104+ check->runChecks (tokenizer, this );
1105+ }
11071106 }
11081107
1109- if (mSettings .clang )
1108+ if (mSettings .clang ) {
11101109 // TODO: Use CTU for Clang analysis
11111110 return ;
1111+ }
11121112
11131113
11141114 if (mSettings .useSingleJob () || !mSettings .buildDir .empty ()) {
@@ -1123,18 +1123,17 @@ void CppCheck::checkNormalTokens(const Tokenizer &tokenizer)
11231123 delete fi1;
11241124 }
11251125
1126- // cppcheck-suppress shadowFunction - TODO: fix this
1127- for (const Check *check : Check::instances ()) {
1128- if (doUnusedFunctionOnly && dynamic_cast <const CheckUnusedFunctions*>(check) == nullptr )
1129- continue ;
1130-
1131- if (Check::FileInfo * const fi = check->getFileInfo (&tokenizer, &mSettings )) {
1132- if (!mSettings .buildDir .empty ())
1133- mAnalyzerInformation .setFileInfo (check->name (), fi->toString ());
1134- if (mSettings .useSingleJob ())
1135- mFileInfo .push_back (fi);
1136- else
1137- delete fi;
1126+ if (!doUnusedFunctionOnly) {
1127+ // cppcheck-suppress shadowFunction - TODO: fix this
1128+ for (const Check *check : Check::instances ()) {
1129+ if (Check::FileInfo * const fi = check->getFileInfo (&tokenizer, &mSettings )) {
1130+ if (!mSettings .buildDir .empty ())
1131+ mAnalyzerInformation .setFileInfo (check->name (), fi->toString ());
1132+ if (mSettings .useSingleJob ())
1133+ mFileInfo .push_back (fi);
1134+ else
1135+ delete fi;
1136+ }
11381137 }
11391138 }
11401139
@@ -1798,7 +1797,7 @@ void CppCheck::analyseWholeProgram(const std::string &buildDir, const std::list<
17981797 return ;
17991798 }
18001799 if (mSettings .checks .isEnabled (Checks::unusedFunction))
1801- CheckUnusedFunctions::analyseWholeProgram2 (mSettings , this , buildDir);
1800+ CheckUnusedFunctions::analyseWholeProgram (mSettings , this , buildDir);
18021801 std::list<Check::FileInfo*> fileInfoList;
18031802 CTU::FileInfo ctuFileInfo;
18041803
0 commit comments