]> granicus.if.org Git - clang/commitdiff
[analyzer] Fix PR11282 - an assert in markAsSink
authorAnna Zaks <ganna@apple.com>
Tue, 1 Nov 2011 22:41:14 +0000 (22:41 +0000)
committerAnna Zaks <ganna@apple.com>
Tue, 1 Nov 2011 22:41:14 +0000 (22:41 +0000)
This is another fallout from the refactoring. We were
calling MarkAsSink on a cached out node.
(Fixes radar://10376675)

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

include/clang/StaticAnalyzer/Core/PathSensitive/CoreEngine.h
include/clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h
lib/StaticAnalyzer/Core/CoreEngine.cpp
test/Analysis/misc-ps.c

index a3e5a19ab2add1d336f91999b55828edf98725c2..2079cdfaffb094897bcda1b50cdf2c6aaa3d75db 100644 (file)
@@ -393,7 +393,7 @@ public:
                     const CFGBlock *dstT, const CFGBlock *dstF)
   : NodeBuilder(SrcNode, DstSet, C), DstT(dstT), DstF(dstF),
     InFeasibleTrue(!DstT), InFeasibleFalse(!DstF) {
-    // The Banch node builder does not generate autotransitions.
+    // The branch node builder does not generate autotransitions.
     // If there are no successors it means that both branches are infeasible.
     takeNodes(SrcNode);
   }
index c824ff51cc96d25a1cb92a8aab9c0f299e65ab9d..0e1cae9580600e7339d3925f73301425fe7a2371 100644 (file)
@@ -389,6 +389,7 @@ public:
 
   void clear() { Impl.clear(); }
   void insert(const ExplodedNodeSet &S) {
+    assert(&S != this);
     if (empty())
       Impl = S.Impl;
     else
index db007feafb845101fb3442c9e3fa801fb488b827..0003e6cd3f3dae859782824977dbf3c73b538a71 100644 (file)
@@ -546,14 +546,17 @@ ExplodedNode* NodeBuilder::generateNodeImpl(const ProgramPoint &Loc,
   ExplodedNode *N = C.Eng.G->getNode(Loc, State, &IsNew);
   N->addPredecessor(FromN, *C.Eng.G);
   Frontier.erase(FromN);
+  assert(IsNew || N->isSink() == MarkAsSink);
+
+  if (!IsNew)
+    return 0;
 
   if (MarkAsSink)
     N->markAsSink();
-    
-  if (IsNew && !MarkAsSink)
+  else
     Frontier.Add(N);
 
-  return (IsNew ? N : 0);
+  return N;
 }
 
 StmtNodeBuilder::~StmtNodeBuilder() {
index be0bbf58ffa98e21ec5ccfaa983dd2a2487a6576..32475f0d0f2b89d0212d56e489f844d989d19f23 100644 (file)
@@ -106,3 +106,17 @@ static int radar10367606(int t) {
   return 0;
 }
 
+/* Caching out on a sink node. */
+extern int fooR10376675();
+extern int* bazR10376675();
+extern int nR10376675;
+void barR10376675(int *x) {
+  int *pm;
+  if (nR10376675 * 2) {
+    int *pk  = bazR10376675();
+    pm = pk; //expected-warning {{never read}}
+  }
+  do {
+    *x = fooR10376675();
+  } while (0);
+}