Fix issue 10106: FP: nullPointerRedundantCheck (#3044)
This commit is contained in:
parent
b469da1069
commit
b571e9fe0b
|
@ -377,7 +377,7 @@ void execute(const Token *expr,
|
|||
if (!expr)
|
||||
*error = true;
|
||||
|
||||
else if (expr->hasKnownIntValue()) {
|
||||
else if (expr->hasKnownIntValue() && !expr->isAssignmentOp()) {
|
||||
*result = expr->values().front().intvalue;
|
||||
}
|
||||
|
||||
|
|
|
@ -431,6 +431,11 @@ static void setTokenValue(Token* tok, const ValueFlow::Value &value, const Setti
|
|||
if (!parent)
|
||||
return;
|
||||
|
||||
if (Token::simpleMatch(parent, "=") && astIsRHS(tok) && !value.isLifetimeValue()) {
|
||||
setTokenValue(parent, value, settings);
|
||||
return;
|
||||
}
|
||||
|
||||
if (value.isContainerSizeValue()) {
|
||||
// .empty, .size, +"abc", +'a'
|
||||
if (Token::Match(parent, "+|==|!=") && parent->astOperand1() && parent->astOperand2()) {
|
||||
|
|
|
@ -4051,7 +4051,7 @@ private:
|
|||
" return((n=42) && *n == 'A');\n"
|
||||
"}";
|
||||
values = tokenValues(code, "n ==");
|
||||
ASSERT_EQUALS(true, values.size() != 1U || !values.front().isUninitValue());
|
||||
ASSERT_EQUALS(true, values.empty());
|
||||
|
||||
// #8233
|
||||
code = "void foo() {\n"
|
||||
|
|
Loading…
Reference in New Issue