ExprEngine; Slow processing
This commit is contained in:
parent
5142c9e9ed
commit
e5a3dc1a0c
|
@ -1787,13 +1787,17 @@ static ExprEngine::ValuePtr executeExpression(const Token *tok, Data &data)
|
||||||
|
|
||||||
static ExprEngine::ValuePtr createVariableValue(const Variable &var, Data &data);
|
static ExprEngine::ValuePtr createVariableValue(const Variable &var, Data &data);
|
||||||
|
|
||||||
static void execute(const Token *start, const Token *end, Data &data)
|
static void execute(const Token *start, const Token *end, Data &data, int recursion=0)
|
||||||
{
|
{
|
||||||
|
if (++recursion > 20)
|
||||||
|
// FIXME
|
||||||
|
throw VerifyException(start, "ExprEngine: Max recursion limit exceeded");
|
||||||
|
|
||||||
for (const Token *tok = start; tok != end; tok = tok->next()) {
|
for (const Token *tok = start; tok != end; tok = tok->next()) {
|
||||||
if (Token::Match(tok, "[;{}]"))
|
if (Token::Match(tok, "[;{}]"))
|
||||||
data.trackProgramState(tok);
|
data.trackProgramState(tok);
|
||||||
|
|
||||||
if (Token::simpleMatch(tok, "while ( 0 ) ;")) {
|
if (Token::simpleMatch(tok, "while (") && (tok->linkAt(1), ") ;") && tok->next()->astOperand1()->hasKnownIntValue() && tok->next()->astOperand1()->getKnownIntValue() == 0) {
|
||||||
tok = tok->tokAt(4);
|
tok = tok->tokAt(4);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -1850,16 +1854,13 @@ static void execute(const Token *start, const Token *end, Data &data)
|
||||||
const Token *thenStart = tok->linkAt(1)->next();
|
const Token *thenStart = tok->linkAt(1)->next();
|
||||||
const Token *thenEnd = thenStart->link();
|
const Token *thenEnd = thenStart->link();
|
||||||
|
|
||||||
if (Token::Match(thenStart, "{ return|throw|break|continue"))
|
execute(thenStart->next(), end, thenData, recursion);
|
||||||
execute(thenStart->next(), thenEnd, thenData);
|
|
||||||
else
|
|
||||||
execute(thenStart->next(), end, thenData);
|
|
||||||
|
|
||||||
if (Token::simpleMatch(thenEnd, "} else {")) {
|
if (Token::simpleMatch(thenEnd, "} else {")) {
|
||||||
const Token *elseStart = thenEnd->tokAt(2);
|
const Token *elseStart = thenEnd->tokAt(2);
|
||||||
execute(elseStart->next(), end, elseData);
|
execute(elseStart->next(), end, elseData, recursion);
|
||||||
} else {
|
} else {
|
||||||
execute(thenEnd, end, elseData);
|
execute(thenEnd, end, elseData, recursion);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1151,6 +1151,14 @@ void Token::printOut(const char *title, const std::vector<std::string> &fileName
|
||||||
std::cout << stringifyList(true, true, true, true, true, &fileNames, nullptr) << std::endl;
|
std::cout << stringifyList(true, true, true, true, true, &fileNames, nullptr) << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Token::printLines(int lines) const
|
||||||
|
{
|
||||||
|
const Token *end = this;
|
||||||
|
while (end && end->linenr() < lines + linenr())
|
||||||
|
end = end->next();
|
||||||
|
std::cout << stringifyList(true, true, true, true, true, nullptr, end) << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
void Token::stringify(std::ostream& os, bool varid, bool attributes, bool macro) const
|
void Token::stringify(std::ostream& os, bool varid, bool attributes, bool macro) const
|
||||||
{
|
{
|
||||||
if (attributes) {
|
if (attributes) {
|
||||||
|
|
|
@ -783,6 +783,11 @@ public:
|
||||||
*/
|
*/
|
||||||
void printOut(const char *title, const std::vector<std::string> &fileNames) const;
|
void printOut(const char *title, const std::vector<std::string> &fileNames) const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* print out tokens
|
||||||
|
*/
|
||||||
|
void printLines(int lines=5) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Replace token replaceThis with tokens between start and end,
|
* Replace token replaceThis with tokens between start and end,
|
||||||
* including start and end. The replaceThis token is deleted.
|
* including start and end. The replaceThis token is deleted.
|
||||||
|
|
Loading…
Reference in New Issue