Fixed #7573 (Tokenizer: FP caused by constant folding)
This commit is contained in:
parent
fee0e4edfa
commit
254e5675ff
|
@ -3364,12 +3364,6 @@ bool Tokenizer::simplifyTokenList1(const char FileName[])
|
||||||
// Combine tokens..
|
// Combine tokens..
|
||||||
combineOperators();
|
combineOperators();
|
||||||
|
|
||||||
// simplify simple calculations
|
|
||||||
for (Token *tok = list.front() ? list.front()->next() : nullptr; tok; tok = tok->next()) {
|
|
||||||
if (tok->isNumber())
|
|
||||||
TemplateSimplifier::simplifyNumericCalculations(tok->previous());
|
|
||||||
}
|
|
||||||
|
|
||||||
// remove extern "C" and extern "C" {}
|
// remove extern "C" and extern "C" {}
|
||||||
if (isCPP())
|
if (isCPP())
|
||||||
simplifyExternC();
|
simplifyExternC();
|
||||||
|
@ -3405,6 +3399,25 @@ bool Tokenizer::simplifyTokenList1(const char FileName[])
|
||||||
// Remove "volatile", "inline", "register", and "restrict"
|
// Remove "volatile", "inline", "register", and "restrict"
|
||||||
simplifyKeyword();
|
simplifyKeyword();
|
||||||
|
|
||||||
|
// simplify simple calculations inside <..>
|
||||||
|
if (isCPP()) {
|
||||||
|
Token *lt = nullptr;
|
||||||
|
for (Token *tok = list.front(); tok; tok = tok->next()) {
|
||||||
|
if (Token::Match(tok, "[;{}]"))
|
||||||
|
lt = nullptr;
|
||||||
|
else if (Token::Match(tok, "%type <"))
|
||||||
|
lt = tok->next();
|
||||||
|
else if (lt && Token::Match(tok, ">|>> %name%|::|(")) {
|
||||||
|
const Token * const end = tok;
|
||||||
|
for (tok = lt; tok != end; tok = tok->next()) {
|
||||||
|
if (tok->isNumber())
|
||||||
|
TemplateSimplifier::simplifyNumericCalculations(tok->previous());
|
||||||
|
}
|
||||||
|
lt = tok->next();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Convert K&R function declarations to modern C
|
// Convert K&R function declarations to modern C
|
||||||
simplifyVarDecl(true);
|
simplifyVarDecl(true);
|
||||||
simplifyFunctionParameters();
|
simplifyFunctionParameters();
|
||||||
|
|
|
@ -765,6 +765,9 @@ static void valueFlowBitAnd(TokenList *tokenlist)
|
||||||
if (tok->str() != "&")
|
if (tok->str() != "&")
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
if (tok->values.size() == 1U && tok->values.front().isKnown())
|
||||||
|
continue;
|
||||||
|
|
||||||
if (!tok->astOperand1() || !tok->astOperand2())
|
if (!tok->astOperand1() || !tok->astOperand2())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue