[cfe-commits] r77353 - in /cfe/trunk: include/clang/Analysis/PathSensitive/Checker.h lib/Analysis/GRExprEngineInternalChecks.cpp test/Analysis/uninit-vals-ps.c

Ted Kremenek kremenek at apple.com
Tue Jul 28 12:24:31 PDT 2009


Author: kremenek
Date: Tue Jul 28 14:24:31 2009
New Revision: 77353

URL: http://llvm.org/viewvc/llvm-project?rev=77353&view=rev
Log:
Fix regression in attribute 'nonnull' checking when a transition node
was created but not added to the destination NodeSet.  This fixes PR 4630.

Modified:
    cfe/trunk/include/clang/Analysis/PathSensitive/Checker.h
    cfe/trunk/lib/Analysis/GRExprEngineInternalChecks.cpp
    cfe/trunk/test/Analysis/uninit-vals-ps.c

Modified: cfe/trunk/include/clang/Analysis/PathSensitive/Checker.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/PathSensitive/Checker.h?rev=77353&r1=77352&r2=77353&view=diff

==============================================================================
--- cfe/trunk/include/clang/Analysis/PathSensitive/Checker.h (original)
+++ cfe/trunk/include/clang/Analysis/PathSensitive/Checker.h Tue Jul 28 14:24:31 2009
@@ -72,6 +72,10 @@
     return B.generateNode(S, state, Pred);
   }
   
+  void addTransition(ExplodedNode<GRState> *node) {
+    Dst.Add(node);
+  }
+  
   void EmitReport(BugReport *R) {
     Eng.getBugReporter().EmitReport(R);
   }

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

==============================================================================
--- cfe/trunk/lib/Analysis/GRExprEngineInternalChecks.cpp (original)
+++ cfe/trunk/lib/Analysis/GRExprEngineInternalChecks.cpp Tue Jul 28 14:24:31 2009
@@ -616,7 +616,7 @@
     // If we reach here all of the arguments passed the nonnull check.
     // If 'state' has been updated generated a new node.
     if (state != originalState)
-      C.generateNode(CE, state);
+      C.addTransition(C.generateNode(CE, state));
   }
 };
 } // end anonymous namespace

Modified: cfe/trunk/test/Analysis/uninit-vals-ps.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/uninit-vals-ps.c?rev=77353&r1=77352&r2=77353&view=diff

==============================================================================
--- cfe/trunk/test/Analysis/uninit-vals-ps.c (original)
+++ cfe/trunk/test/Analysis/uninit-vals-ps.c Tue Jul 28 14:24:31 2009
@@ -84,3 +84,21 @@
   return CFStringConvertEncodingToIANACharSetName(encoding); // no-warning
 }
 
+// PR 4630 - false warning with nonnull attribute
+//  This false positive (due to a regression) caused the analyzer to falsely
+//  flag a "return of uninitialized value" warning in the first branch due to
+//  the nonnull attribute.
+void pr_4630_aux(char *x, int *y) __attribute__ ((nonnull (1)));
+void pr_4630_aux_2(char *x, int *y);
+int pr_4630(char *a, int y) {
+  int x;
+  if (y) {
+    pr_4630_aux(a, &x);
+    return x;   // no-warning
+  }
+  else {
+    pr_4630_aux_2(a, &x);
+    return x;   // no-warning
+  }
+}
+





More information about the cfe-commits mailing list