]> granicus.if.org Git - clang/commitdiff
Fix regression in pointer comparison with NULL (e.g., 0 != ptr). This fixes
authorTed Kremenek <kremenek@apple.com>
Sat, 28 Mar 2009 19:59:33 +0000 (19:59 +0000)
committerTed Kremenek <kremenek@apple.com>
Sat, 28 Mar 2009 19:59:33 +0000 (19:59 +0000)
<rdar://problem/6732151>.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67954 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Analysis/GRSimpleVals.cpp
test/Analysis/CheckNSError.m

index a38d76d2608049d129139947270aea6729d94565..8e605ca4c783835da29ba9dbc561fca091e4f490 100644 (file)
@@ -375,13 +375,11 @@ 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,
-                                    cast<loc::ConcreteInt>(L).getValue(),
-                                    Eng.getContext().IntTy);
+          Eng.getSymbolManager().getSymIntExpr(Sym, BinaryOperator::NE,
+                                           cast<loc::ConcreteInt>(L).getValue(),
+                                             Eng.getContext().IntTy);
         return nonloc::SymExprVal(SE);
       }
       
index 28435727eb79506db5ffa74d69aa5330e8fca047..779b865aff8cb077f28ae1cca40b780a6266e2c6 100644 (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;
+}
+
+