forked from OSchip/llvm-project
If a nonnull argument evaluates to UnknownVal, don't warn (and don't crash).
llvm-svn: 106456
This commit is contained in:
parent
fa1b54d26e
commit
3d85888d4e
|
@ -60,11 +60,16 @@ void AttrNonNullChecker::PreVisitCallExpr(CheckerContext &C,
|
|||
if (!Att->isNonNull(idx))
|
||||
continue;
|
||||
|
||||
const DefinedSVal &V = cast<DefinedSVal>(state->getSVal(*I));
|
||||
SVal V = state->getSVal(*I);
|
||||
DefinedSVal *DV = dyn_cast<DefinedSVal>(&V);
|
||||
|
||||
// If the value is unknown or undefined, we can't perform this check.
|
||||
if (!DV)
|
||||
continue;
|
||||
|
||||
ConstraintManager &CM = C.getConstraintManager();
|
||||
const GRState *stateNotNull, *stateNull;
|
||||
llvm::tie(stateNotNull, stateNull) = CM.AssumeDual(state, V);
|
||||
llvm::tie(stateNotNull, stateNull) = CM.AssumeDual(state, *DV);
|
||||
|
||||
if (stateNull && !stateNotNull) {
|
||||
// Generate an error node. Check for a null node in case
|
||||
|
|
|
@ -118,6 +118,11 @@ void f6d(int *p) {
|
|||
}
|
||||
}
|
||||
|
||||
void f6e(int *p, int offset) {
|
||||
// PR7406 - crash from treating an UnknownVal as defined, to see if it's 0.
|
||||
bar((p+offset)+1, 0); // not crash
|
||||
}
|
||||
|
||||
int* qux();
|
||||
|
||||
int f7(int x) {
|
||||
|
|
Loading…
Reference in New Issue