From c7155a8e08315124ad4e92fdab04ff6777236232 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Sun, 17 Mar 2019 08:19:56 +0100 Subject: [PATCH] Removed '--experimental-fast' flag --- cli/cmdlineparser.cpp | 5 ++--- lib/cppcheck.cpp | 36 ++++++++++++++++-------------------- lib/cppcheck.h | 9 +++------ lib/settings.cpp | 1 - lib/settings.h | 5 ----- tools/donate-cpu.py | 15 ++------------- 6 files changed, 23 insertions(+), 48 deletions(-) diff --git a/cli/cmdlineparser.cpp b/cli/cmdlineparser.cpp index 37db84db8..ca8145f04 100644 --- a/cli/cmdlineparser.cpp +++ b/cli/cmdlineparser.cpp @@ -170,9 +170,8 @@ bool CmdLineParser::parseFromArgs(int argc, const char* const argv[]) mSettings->maxCtuDepth = std::atoi(argv[i] + 16); else if (std::strcmp(argv[i], "--experimental-fast") == 0) - // Skip slow simplifications and see how that affect the results, the - // goal is to remove the simplifications. - mSettings->experimentalFast = true; + // TODO: Reomve this flag! + ; // (Experimental) exception handling inside cppcheck client else if (std::strcmp(argv[i], "--exception-handling") == 0) diff --git a/lib/cppcheck.cpp b/lib/cppcheck.cpp index 572df2a91..392889c76 100644 --- a/lib/cppcheck.cpp +++ b/lib/cppcheck.cpp @@ -435,18 +435,16 @@ unsigned int CppCheck::checkFile(const std::string& filename, const std::string checkUnusedFunctions.parseTokens(mTokenizer, filename.c_str(), &mSettings); // simplify more if required, skip rest of iteration if failed - if (mSimplify) { - if (!mSettings.experimentalFast) { + if (mSimplify && hasRule("simple")) { // if further simplification fails then skip rest of iteration Timer timer3("Tokenizer::simplifyTokenList2", mSettings.showtime, &S_timerResults); result = mTokenizer.simplifyTokenList2(); timer3.Stop(); if (!result) continue; - } - // Check simplified tokens - checkSimplifiedTokens(mTokenizer); + if (!mSettings.terminated()) + executeRules("simple", mTokenizer); } } catch (const simplecpp::Output &o) { @@ -604,16 +602,22 @@ void CppCheck::checkNormalTokens(const Tokenizer &tokenizer) executeRules("normal", tokenizer); } -//--------------------------------------------------------------------------- -// CppCheck - A function that checks a simplified token list //--------------------------------------------------------------------------- -void CppCheck::checkSimplifiedTokens(const Tokenizer &tokenizer) +bool CppCheck::hasRule(const std::string &tokenlist) const { - if (!mSettings.terminated()) - executeRules("simple", tokenizer); +#ifdef HAVE_RULES + for (const Settings::Rule &rule : mSettings.rules) { + if (rule.tokenlist == tokenlist) + return true; + } +#else + (void)tokenlist; +#endif + return false; } + #ifdef HAVE_RULES static const char * pcreErrorCodeToString(const int pcreExecRet) @@ -754,15 +758,8 @@ void CppCheck::executeRules(const std::string &tokenlist, const Tokenizer &token (void)tokenizer; #ifdef HAVE_RULES - // Are there rules to execute? - bool isrule = false; - for (std::list::const_iterator it = mSettings.rules.begin(); it != mSettings.rules.end(); ++it) { - if (it->tokenlist == tokenlist) - isrule = true; - } - // There is no rule to execute - if (isrule == false) + if (!hasRule(tokenlist)) return; // Write all tokens in a string that can be parsed by pcre @@ -771,8 +768,7 @@ void CppCheck::executeRules(const std::string &tokenlist, const Tokenizer &token ostr << " " << tok->str(); const std::string str(ostr.str()); - for (std::list::const_iterator it = mSettings.rules.begin(); it != mSettings.rules.end(); ++it) { - const Settings::Rule &rule = *it; + for (const Settings::Rule &rule : mSettings.rules) { if (rule.pattern.empty() || rule.id.empty() || rule.severity == Severity::none || rule.tokenlist != tokenlist) continue; diff --git a/lib/cppcheck.h b/lib/cppcheck.h index 62730aa39..0e27aa61d 100644 --- a/lib/cppcheck.h +++ b/lib/cppcheck.h @@ -145,6 +145,9 @@ public: private: + /** Are there "simple" rules */ + bool hasRule(const std::string &tokenlist) const; + /** @brief There has been an internal error => Report information message */ void internalError(const std::string &filename, const std::string &msg); @@ -169,12 +172,6 @@ private: */ void checkNormalTokens(const Tokenizer &tokenizer); - /** - * @brief Check simplified tokens - * @param tokenizer tokenizer instance - */ - void checkSimplifiedTokens(const Tokenizer &tokenizer); - /** * @brief Execute rules, if any * @param tokenlist token list to use (normal / simple) diff --git a/lib/settings.cpp b/lib/settings.cpp index 178f18649..1845f29ce 100644 --- a/lib/settings.cpp +++ b/lib/settings.cpp @@ -34,7 +34,6 @@ Settings::Settings() inconclusive(false), jointSuppressionReport(false), experimental(false), - experimentalFast(false), quiet(false), inlineSuppressions(false), verbose(false), diff --git a/lib/settings.h b/lib/settings.h index 5d6290b4f..fe9f4b3d0 100644 --- a/lib/settings.h +++ b/lib/settings.h @@ -111,11 +111,6 @@ public: */ bool experimental; - /** Experimental "fast" checking. We skip slow simplifications. The - * goal is that there will not be significant effect on the results - * and that we can remove the slow simplifications. */ - bool experimentalFast; - /** @brief Is --quiet given? */ bool quiet; diff --git a/tools/donate-cpu.py b/tools/donate-cpu.py index 58765dabe..026a5a136 100644 --- a/tools/donate-cpu.py +++ b/tools/donate-cpu.py @@ -229,7 +229,7 @@ def hasInclude(path, includes): return False -def scanPackage(workPath, cppcheckPath, jobs, fast): +def scanPackage(workPath, cppcheckPath, jobs): print('Analyze..') os.chdir(workPath) libraries = ' --library=posix --library=gnu' @@ -257,8 +257,6 @@ def scanPackage(workPath, cppcheckPath, jobs, fast): # Reference for GNU C: https://gcc.gnu.org/onlinedocs/cpp/Common-Predefined-Macros.html options = jobs + libraries + ' -D__GNUC__ --check-library --inconclusive --enable=style,information --platform=unix64 --template=daca2 -rp=temp temp' - if fast: - options = '--experimental-fast ' + options cmd = 'nice ' + cppcheckPath + '/cppcheck' + ' ' + options print(cmd) startTime = time.time() @@ -506,7 +504,7 @@ while True: current_cppcheck_dir = 'cppcheck' else: current_cppcheck_dir = ver - c, errout, info, t, cppcheck_options = scanPackage(workpath, current_cppcheck_dir, jobs, False) + c, errout, info, t, cppcheck_options = scanPackage(workpath, current_cppcheck_dir, jobs) if c < 0: crash = True count += ' Crash!' @@ -517,15 +515,6 @@ while True: if ver == 'head': head_info_msg = info - # Fast results - fast_c, fast_errout, fast_info, fast_t, fast_cppcheck_options = scanPackage(workpath, current_cppcheck_dir, jobs, True) - if c > 0 and errout and fast_errout: - output = 'FAST\n' - output += 'elapsed-time: %.1f %.1f' % (t, fast_t) - output += '\ndiff:\n' - output += diffResults(workpath, 'head', errout, 'fast', fast_errout) - uploadResults(package, output, server_address) - results_exist = True if len(resultsToDiff[0]) + len(resultsToDiff[1]) == 0: results_exist = False