DACA: Try to avoid some crashes/hangs for the most crazy code so we can focus on most serious bugs first

This commit is contained in:
Daniel Marjamäki 2020-03-31 11:33:22 +02:00
parent 28cd5d7ea2
commit 7577bdb1df
4 changed files with 19 additions and 0 deletions

View File

@ -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")

View File

@ -36,6 +36,7 @@ Settings::Settings()
checkUnusedTemplates(false),
clang(false),
clangTidy(false),
daca(false),
debugSimplified(false),
debugnormal(false),
debugwarnings(false),

View File

@ -105,6 +105,9 @@ public:
/** @brief include paths excluded from checking the configuration */
std::set<std::string> configExcludePaths;
/** @brief Are we running from DACA script? */
bool daca;
/** @brief Is --debug-simplified given? */
bool debugSimplified;

View File

@ -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();