Fix regression in pointer comparison with NULL (e.g., 0 != ptr). This fixes

<rdar://problem/6732151>.

llvm-svn: 67954
This commit is contained in:
Ted Kremenek 2009-03-28 19:59:33 +00:00
parent 356d974a93
commit 035cf930d5
2 changed files with 18 additions and 8 deletions

View File

@ -375,11 +375,9 @@ TryAgain:
return NonLoc::MakeIntTruthVal(BasicVals, b);
}
else if (isa<loc::SymbolVal>(R)) {
else if (SymbolRef Sym = R.getAsSymbol()) {
const SymIntExpr * SE =
Eng.getSymbolManager().getSymIntExpr(
cast<loc::SymbolVal>(R).getSymbol(),
BinaryOperator::NE,
Eng.getSymbolManager().getSymIntExpr(Sym, BinaryOperator::NE,
cast<loc::ConcreteInt>(L).getValue(),
Eng.getContext().IntTy);
return nonloc::SymExprVal(SE);

View File

@ -41,7 +41,19 @@ void foo(CFErrorRef* error) { // expected-warning {{Function accepting CFErrorRe
*error = 0; // expected-warning {{Potential null dereference.}}
}
int bar(CFErrorRef* error) {
if (error) *error = 0;
int f1(CFErrorRef* error) {
if (error) *error = 0; // no-warning
return 0;
}
int f2(CFErrorRef* error) {
if (0 != error) *error = 0; // no-warning
return 0;
}
int f3(CFErrorRef* error) {
if (error != 0) *error = 0; // no-warning
return 0;
}