diff --git a/cli/cmdlineparser.cpp b/cli/cmdlineparser.cpp index 785a4f991..f517107f0 100644 --- a/cli/cmdlineparser.cpp +++ b/cli/cmdlineparser.cpp @@ -664,6 +664,7 @@ bool CmdLineParser::parseFromArgs(int argc, const char* const argv[]) mSettings->templateFormat = "{file}:{line}:{column}: warning: {message} [{id}]\\n{code}"; mSettings->templateLocation = "{file}:{line}:{column}: note: {info}\\n{code}"; } else if (mSettings->templateFormat == "daca2") { + mSettings->daca = true; mSettings->templateFormat = "{file}:{line}:{column}: {severity}: {message} [{id}]"; mSettings->templateLocation = "{file}:{line}:{column}: note: {info}"; } else if (mSettings->templateFormat == "vs") diff --git a/lib/settings.cpp b/lib/settings.cpp index 589e18437..b48158771 100644 --- a/lib/settings.cpp +++ b/lib/settings.cpp @@ -36,6 +36,7 @@ Settings::Settings() checkUnusedTemplates(false), clang(false), clangTidy(false), + daca(false), debugSimplified(false), debugnormal(false), debugwarnings(false), diff --git a/lib/settings.h b/lib/settings.h index 0e5aaad0f..8cc9eafa4 100644 --- a/lib/settings.h +++ b/lib/settings.h @@ -105,6 +105,9 @@ public: /** @brief include paths excluded from checking the configuration */ std::set configExcludePaths; + /** @brief Are we running from DACA script? */ + bool daca; + /** @brief Is --debug-simplified given? */ bool debugSimplified; diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index c82a6c7fd..d9ee852e2 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -4297,6 +4297,20 @@ bool Tokenizer::simplifyTokenList1(const char FileName[]) } } + // Some special bailouts in DACA. To avoid too much hangs/crashes. + // FIXME: This is hopefully temporary. Somehow it should not be used in releases. + if (mSettings->daca) { + int numcase = 0; + for (const Token *tok = list.front(); tok; tok = tok->next()) { + if (Token::Match(tok, "%name% [ %num% ] = {") && MathLib::toLongNumber(tok->strAt(2)) > 10000) + return false; + if (tok->str() == "case") { + if (++numcase > 10000) + return false; + } + } + } + // Is there C++ code in C file? validateC();