ValueFlow: For convenience, return constant folded value
This commit is contained in:
parent
b26dd1ccab
commit
b94eaeca6a
|
@ -2377,13 +2377,14 @@ static void valueFlowFunctionReturn(TokenList *tokenlist, ErrorLogger *errorLogg
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ValueFlow::valueFlowConstantFoldAST(const Token *expr)
|
const ValueFlow::Value *ValueFlow::valueFlowConstantFoldAST(const Token *expr)
|
||||||
{
|
{
|
||||||
if (!expr || !expr->values.empty())
|
if (expr && expr->values.empty()) {
|
||||||
return;
|
valueFlowConstantFoldAST(expr->astOperand1());
|
||||||
valueFlowConstantFoldAST(expr->astOperand1());
|
valueFlowConstantFoldAST(expr->astOperand2());
|
||||||
valueFlowConstantFoldAST(expr->astOperand2());
|
valueFlowSetConstantValue(expr);
|
||||||
valueFlowSetConstantValue(expr);
|
}
|
||||||
|
return expr && expr->values.size() == 1U && expr->values.front().isKnown() ? &expr->values.front() : nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -95,7 +95,7 @@ namespace ValueFlow {
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Constant folding of expression. This can be used before the full ValueFlow has been executed (ValueFlow::setValues).
|
/// Constant folding of expression. This can be used before the full ValueFlow has been executed (ValueFlow::setValues).
|
||||||
void valueFlowConstantFoldAST(const Token *expr);
|
const ValueFlow::Value * valueFlowConstantFoldAST(const Token *expr);
|
||||||
|
|
||||||
/// Perform valueflow analysis.
|
/// Perform valueflow analysis.
|
||||||
void setValues(TokenList *tokenlist, SymbolDatabase* symboldatabase, ErrorLogger *errorLogger, const Settings *settings);
|
void setValues(TokenList *tokenlist, SymbolDatabase* symboldatabase, ErrorLogger *errorLogger, const Settings *settings);
|
||||||
|
|
Loading…
Reference in New Issue