[cfe-commits] r67954 - in /cfe/trunk: lib/Analysis/GRSimpleVals.cpp test/Analysis/CheckNSError.m

Ted Kremenek kremenek at apple.com
Sat Mar 28 12:59:33 PDT 2009


Author: kremenek
Date: Sat Mar 28 14:59:33 2009
New Revision: 67954

URL: http://llvm.org/viewvc/llvm-project?rev=67954&view=rev
Log:
Fix regression in pointer comparison with NULL (e.g., 0 != ptr). This fixes
<rdar://problem/6732151>.

Modified:
    cfe/trunk/lib/Analysis/GRSimpleVals.cpp
    cfe/trunk/test/Analysis/CheckNSError.m

Modified: cfe/trunk/lib/Analysis/GRSimpleVals.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/GRSimpleVals.cpp?rev=67954&r1=67953&r2=67954&view=diff

==============================================================================
--- cfe/trunk/lib/Analysis/GRSimpleVals.cpp (original)
+++ cfe/trunk/lib/Analysis/GRSimpleVals.cpp Sat Mar 28 14:59:33 2009
@@ -375,13 +375,11 @@
         
         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);
       }
       

Modified: cfe/trunk/test/Analysis/CheckNSError.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/CheckNSError.m?rev=67954&r1=67953&r2=67954&view=diff

==============================================================================
--- cfe/trunk/test/Analysis/CheckNSError.m (original)
+++ cfe/trunk/test/Analysis/CheckNSError.m Sat Mar 28 14:59:33 2009
@@ -41,7 +41,19 @@
   *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;
+}
+
+





More information about the cfe-commits mailing list