ExprEngine: Handle 'break' and 'while (0);'

This commit is contained in:
Daniel Marjamäki 2019-10-06 17:43:30 +02:00
parent dcf8a7213f
commit 6c0c9ba6d3
1 changed files with 13 additions and 0 deletions

View File

@ -563,6 +563,11 @@ struct ExprData {
getExpr(c->values[0].second));
}
if (auto integerTruncation = std::dynamic_pointer_cast<ExprEngine::IntegerTruncation>(v)) {
return getExpr(integerTruncation->inputValue);
//return getExpr(integerTruncation->inputValue) & ((1 << integerTruncation->bits) - 1);
}
if (v->type == ExprEngine::ValueType::UninitValue)
return context.int_val(0);
@ -1036,6 +1041,14 @@ static void execute(const Token *start, const Token *end, Data &data)
if (Token::Match(tok, "[;{}]"))
data.trackProgramState(tok);
if (Token::simpleMatch(tok, "while ( 0 ) ;")) {
tok = tok->tokAt(4);
continue;
}
if (tok->str() == "break")
return;
if (Token::Match(tok, "for|while|switch ("))
// TODO this is a bailout
throw std::runtime_error("Unhandled:" + tok->str());