]> granicus.if.org Git - clang/commitdiff
Fix regression in attribute 'nonnull' checking when a transition node
authorTed Kremenek <kremenek@apple.com>
Tue, 28 Jul 2009 19:24:31 +0000 (19:24 +0000)
committerTed Kremenek <kremenek@apple.com>
Tue, 28 Jul 2009 19:24:31 +0000 (19:24 +0000)
was created but not added to the destination NodeSet.  This fixes PR 4630.

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

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

index 611a135e6c11fba63586fbf4566a0c7de3297321..f70b6129c4f3bc7228cfb3f620234fb12bb5e714 100644 (file)
@@ -72,6 +72,10 @@ public:
     return B.generateNode(S, state, Pred);
   }
   
+  void addTransition(ExplodedNode<GRState> *node) {
+    Dst.Add(node);
+  }
+  
   void EmitReport(BugReport *R) {
     Eng.getBugReporter().EmitReport(R);
   }
index 06fe5b8267ebcf0cec67ef87ee6142b3039bff01..f3ee5b6418c4c36a41ba47d5a39d69cc36314ae9 100644 (file)
@@ -616,7 +616,7 @@ public:
     // 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
index 622b04f8438a839f9b5da37abc901fe31717a54d..4482b1323654331eed676fa2a9fa604a8c240162 100644 (file)
@@ -84,3 +84,21 @@ CFStringRef rdar_6451816(CFNumberRef nr) {
   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
+  }
+}
+