forked from OSchip/llvm-project
[analyzer] Fix tracking expressions through negation operator
Differential Revision: https://reviews.llvm.org/D50537 llvm-svn: 339476
This commit is contained in:
parent
09a9e3abfe
commit
b5dd3ccdbd
|
@ -1560,6 +1560,10 @@ static const Expr *peelOffOuterExpr(const Expr *Ex,
|
||||||
if (const Expr *SubEx = peelOffPointerArithmetic(BO))
|
if (const Expr *SubEx = peelOffPointerArithmetic(BO))
|
||||||
return peelOffOuterExpr(SubEx, N);
|
return peelOffOuterExpr(SubEx, N);
|
||||||
|
|
||||||
|
if (auto *UO = dyn_cast<UnaryOperator>(Ex))
|
||||||
|
if (UO->getOpcode() == UO_LNot)
|
||||||
|
return peelOffOuterExpr(UO->getSubExpr(), N);
|
||||||
|
|
||||||
return Ex;
|
return Ex;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -357,3 +357,18 @@ int forceElementRegionApperence() {
|
||||||
return ((HasFieldB*)&a)->x; // expected-warning{{Undefined or garbage value returned to caller}}
|
return ((HasFieldB*)&a)->x; // expected-warning{{Undefined or garbage value returned to caller}}
|
||||||
// expected-note@-1{{Undefined or garbage value returned to caller}}
|
// expected-note@-1{{Undefined or garbage value returned to caller}}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////
|
||||||
|
|
||||||
|
struct HasForgottenField {
|
||||||
|
int x;
|
||||||
|
HasForgottenField() {} // expected-note{{Returning without writing to 'this->x'}}
|
||||||
|
};
|
||||||
|
|
||||||
|
// Test that tracking across exclamation mark works.
|
||||||
|
bool tracksThroughExclamationMark() {
|
||||||
|
HasForgottenField a; // expected-note{{Calling default constructor for 'HasForgottenField'}}
|
||||||
|
// expected-note@-1{{Returning from default constructor for 'HasForgottenField'}}
|
||||||
|
return !a.x; // expected-warning{{Undefined or garbage value returned to caller}}
|
||||||
|
// expected-note@-1{{Undefined or garbage value returned to caller}}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue