From 4f232e41dd4ce686d1ea49dd2f8b2d1201944366 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Sat, 9 Feb 2019 14:40:50 +0100 Subject: [PATCH] Add --experimental-fast option --- cli/cmdlineparser.cpp | 5 +++++ lib/cppcheck.cpp | 14 ++++++++------ lib/settings.cpp | 1 + lib/settings.h | 5 +++++ 4 files changed, 19 insertions(+), 6 deletions(-) diff --git a/cli/cmdlineparser.cpp b/cli/cmdlineparser.cpp index b8aeaa5a0..16a15b4c8 100644 --- a/cli/cmdlineparser.cpp +++ b/cli/cmdlineparser.cpp @@ -159,6 +159,11 @@ bool CmdLineParser::parseFromArgs(int argc, const char* const argv[]) else if (std::strncmp(argv[i], "--max-ctu-depth=", 16) == 0) 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; + // (Experimental) exception handling inside cppcheck client else if (std::strcmp(argv[i], "--exception-handling") == 0) mSettings->exceptionHandling = true; diff --git a/lib/cppcheck.cpp b/lib/cppcheck.cpp index 964948aba..aaada68da 100644 --- a/lib/cppcheck.cpp +++ b/lib/cppcheck.cpp @@ -436,12 +436,14 @@ unsigned int CppCheck::checkFile(const std::string& filename, const std::string // simplify more if required, skip rest of iteration if failed if (mSimplify) { - // 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; + if (!mSettings.experimentalFast) { + // 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); diff --git a/lib/settings.cpp b/lib/settings.cpp index be82f15db..6d692dc1f 100644 --- a/lib/settings.cpp +++ b/lib/settings.cpp @@ -34,6 +34,7 @@ Settings::Settings() jointSuppressionReport(false), maxCtuDepth(2), experimental(false), + experimentalFast(false), quiet(false), inlineSuppressions(false), verbose(false), diff --git a/lib/settings.h b/lib/settings.h index 0a7932bd3..b39ba49d7 100644 --- a/lib/settings.h +++ b/lib/settings.h @@ -111,6 +111,11 @@ 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;