Verification; Avoid obvious verificationUninit false positives during bailout
This commit is contained in:
parent
d1f3ecec12
commit
88429382b7
|
@ -1748,9 +1748,14 @@ void ExprEngine::executeFunction(const Scope *functionScope, const Tokenizer *to
|
||||||
} catch (VerifyException &e) {
|
} catch (VerifyException &e) {
|
||||||
trackExecution.setAbortLine(e.tok->linenr());
|
trackExecution.setAbortLine(e.tok->linenr());
|
||||||
auto bailoutValue = std::make_shared<BailoutValue>();
|
auto bailoutValue = std::make_shared<BailoutValue>();
|
||||||
for (const Token *tok = e.tok; tok != functionScope->bodyEnd; tok = tok->next())
|
for (const Token *tok = e.tok; tok != functionScope->bodyEnd; tok = tok->next()) {
|
||||||
|
if (Token::Match(tok, "return|throw|while|if|for (")) {
|
||||||
|
tok = tok->next();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
call(callbacks, tok, bailoutValue, &data);
|
call(callbacks, tok, bailoutValue, &data);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (settings->debugVerification && (settings->verbose || callbacks.empty() || !trackExecution.isAllOk())) {
|
if (settings->debugVerification && (settings->verbose || callbacks.empty() || !trackExecution.isAllOk())) {
|
||||||
if (!settings->verificationReport.empty())
|
if (!settings->verificationReport.empty())
|
||||||
|
@ -1857,6 +1862,26 @@ void ExprEngine::runChecks(ErrorLogger *errorLogger, const Tokenizer *tokenizer,
|
||||||
if (!value.isUninit())
|
if (!value.isUninit())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
// Avoid FP when there is bailout..
|
||||||
|
if (value.type == ExprEngine::ValueType::BailoutValue) {
|
||||||
|
if (tok->str() == "(")
|
||||||
|
// cast: result is not uninitialized if expression is initialized
|
||||||
|
// function: does not return a uninitialized value
|
||||||
|
return;
|
||||||
|
|
||||||
|
const Token *tokens[] = {tok, tok->astOperand1(), tok->astOperand2()};
|
||||||
|
for (const Token *t: tokens) {
|
||||||
|
if (t && t->valueType() && t->valueType()->pointer == 0 && t->valueType()->container)
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const Variable *var = tok->variable();
|
||||||
|
if (var && !var->isPointer()) {
|
||||||
|
if (!var->isLocal() || var->isStatic())
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Avoid FP for array declaration
|
// Avoid FP for array declaration
|
||||||
const Token *parent = tok->astParent();
|
const Token *parent = tok->astParent();
|
||||||
while (parent && parent->str() == "[")
|
while (parent && parent->str() == "[")
|
||||||
|
|
Loading…
Reference in New Issue