@@ -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 if (mSettings .library .markupFile (filename)) {
@@ -1074,39 +1074,39 @@ void CppCheck::checkNormalTokens(const Tokenizer &tokenizer)
10741074 const char * unusedFunctionOnly = std::getenv (" UNUSEDFUNCTION_ONLY" );
10751075 const bool doUnusedFunctionOnly = unusedFunctionOnly && (std::strcmp (unusedFunctionOnly, " 1" ) == 0 );
10761076
1077- const std::time_t maxTime = mSettings .checksMaxTime > 0 ? std::time (nullptr ) + mSettings .checksMaxTime : 0 ;
1077+ if (!doUnusedFunctionOnly) {
1078+ const std::time_t maxTime = mSettings .checksMaxTime > 0 ? std::time (nullptr ) + mSettings .checksMaxTime : 0 ;
10781079
1079- // call all "runChecks" in all registered Check classes
1080- // cppcheck-suppress shadowFunction - TODO: fix this
1081- for (Check *check : Check::instances ()) {
1082- if (Settings::terminated ())
1083- return ;
1084-
1085- if (maxTime > 0 && std::time (nullptr ) > maxTime) {
1086- if (mSettings .debugwarnings ) {
1087- ErrorMessage::FileLocation loc;
1088- loc.setfile (tokenizer.list .getFiles ()[0 ]);
1089- ErrorMessage errmsg ({std::move (loc)},
1090- emptyString,
1091- Severity::debug,
1092- " Checks maximum time exceeded" ,
1093- " checksMaxTime" ,
1094- Certainty::normal);
1095- reportErr (errmsg);
1080+ // call all "runChecks" in all registered Check classes
1081+ // cppcheck-suppress shadowFunction - TODO: fix this
1082+ for (Check *check : Check::instances ()) {
1083+ if (Settings::terminated ())
1084+ return ;
1085+
1086+ if (maxTime > 0 && std::time (nullptr ) > maxTime) {
1087+ if (mSettings .debugwarnings ) {
1088+ ErrorMessage::FileLocation loc;
1089+ loc.setfile (tokenizer.list .getFiles ()[0 ]);
1090+ ErrorMessage errmsg ({std::move (loc)},
1091+ emptyString,
1092+ Severity::debug,
1093+ " Checks maximum time exceeded" ,
1094+ " checksMaxTime" ,
1095+ Certainty::normal);
1096+ reportErr (errmsg);
1097+ }
1098+ return ;
10961099 }
1097- return ;
1098- }
10991100
1100- if (doUnusedFunctionOnly && dynamic_cast <CheckUnusedFunctions*>(check) == nullptr )
1101- continue ;
1102-
1103- Timer timerRunChecks (check->name () + " ::runChecks" , mSettings .showtime , &s_timerResults);
1104- check->runChecks (tokenizer, this );
1101+ Timer timerRunChecks (check->name () + " ::runChecks" , mSettings .showtime , &s_timerResults);
1102+ check->runChecks (tokenizer, this );
1103+ }
11051104 }
11061105
1107- if (mSettings .clang )
1106+ if (mSettings .clang ) {
11081107 // TODO: Use CTU for Clang analysis
11091108 return ;
1109+ }
11101110
11111111
11121112 if (mSettings .useSingleJob () || !mSettings .buildDir .empty ()) {
@@ -1121,18 +1121,17 @@ void CppCheck::checkNormalTokens(const Tokenizer &tokenizer)
11211121 delete fi1;
11221122 }
11231123
1124- // cppcheck-suppress shadowFunction - TODO: fix this
1125- for (const Check *check : Check::instances ()) {
1126- if (doUnusedFunctionOnly && dynamic_cast <const CheckUnusedFunctions*>(check) == nullptr )
1127- continue ;
1128-
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;
1124+ if (!doUnusedFunctionOnly) {
1125+ // cppcheck-suppress shadowFunction - TODO: fix this
1126+ for (const Check *check : Check::instances ()) {
1127+ if (Check::FileInfo * const fi = check->getFileInfo (&tokenizer, &mSettings )) {
1128+ if (!mSettings .buildDir .empty ())
1129+ mAnalyzerInformation .setFileInfo (check->name (), fi->toString ());
1130+ if (mSettings .useSingleJob ())
1131+ mFileInfo .push_back (fi);
1132+ else
1133+ delete fi;
1134+ }
11361135 }
11371136 }
11381137
@@ -1797,7 +1796,7 @@ void CppCheck::analyseWholeProgram(const std::string &buildDir, const std::list<
17971796 return ;
17981797 }
17991798 if (mSettings .checks .isEnabled (Checks::unusedFunction))
1800- CheckUnusedFunctions::analyseWholeProgram2 (mSettings , this , buildDir);
1799+ CheckUnusedFunctions::analyseWholeProgram (mSettings , this , buildDir);
18011800 std::list<Check::FileInfo*> fileInfoList;
18021801 CTU::FileInfo ctuFileInfo;
18031802
0 commit comments