]> granicus.if.org Git - clang/commitdiff
[analyzer] BranchNodeBuilder should not generate autotransitions.
authorAnna Zaks <ganna@apple.com>
Tue, 1 Nov 2011 22:41:06 +0000 (22:41 +0000)
committerAnna Zaks <ganna@apple.com>
Tue, 1 Nov 2011 22:41:06 +0000 (22:41 +0000)
This fixes radar://10367606

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

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

index 87751d28a3e2f5dc5a004e4d2e1f55f055d61ca3..a3e5a19ab2add1d336f91999b55828edf98725c2 100644 (file)
@@ -378,6 +378,8 @@ public:
   }
 };
 
+/// \brief BranchNodeBuilder is responsible for constructing the nodes
+/// corresponding to the two branches of the if statement - true and false.
 class BranchNodeBuilder: public NodeBuilder {
   const CFGBlock *DstT;
   const CFGBlock *DstF;
@@ -390,13 +392,19 @@ public:
                     const NodeBuilderContext &C,
                     const CFGBlock *dstT, const CFGBlock *dstF)
   : NodeBuilder(SrcNode, DstSet, C), DstT(dstT), DstF(dstF),
-    InFeasibleTrue(!DstT), InFeasibleFalse(!DstF) {}
+    InFeasibleTrue(!DstT), InFeasibleFalse(!DstF) {
+    // The Banch node builder does not generate autotransitions.
+    // If there are no successors it means that both branches are infeasible.
+    takeNodes(SrcNode);
+  }
 
   BranchNodeBuilder(const ExplodedNodeSet &SrcSet, ExplodedNodeSet &DstSet,
                     const NodeBuilderContext &C,
                     const CFGBlock *dstT, const CFGBlock *dstF)
   : NodeBuilder(SrcSet, DstSet, C), DstT(dstT), DstF(dstF),
-    InFeasibleTrue(!DstT), InFeasibleFalse(!DstF) {}
+    InFeasibleTrue(!DstT), InFeasibleFalse(!DstF) {
+    takeNodes(SrcSet);
+  }
 
   ExplodedNode *generateNode(const ProgramState *State, bool branch,
                              ExplodedNode *Pred);
index fa340753e5b73e5e958d3ac370b099bb07af51c8..51aa753f11e9a474bf3be49469ba9648f0197372 100644 (file)
@@ -73,6 +73,7 @@ public:
   }
 
   void enqueue(ExplodedNode *N) {
+    assert(N->getLocation().getKind() != ProgramPoint::PostStmtKind);
     enqueue(WorkListUnit(N, CurrentCounter));
   }
 
index 5ab55b5ee396045f7a55f18d4d0dcc452fa610a7..db007feafb845101fb3442c9e3fa801fb488b827 100644 (file)
@@ -456,6 +456,7 @@ void CoreEngine::generateNode(const ProgramPoint &Loc,
 
 void CoreEngine::enqueueStmtNode(ExplodedNode *N,
                                  const CFGBlock *Block, unsigned Idx) {
+  assert(Block);
   assert (!N->isSink());
 
   // Check if this node entered a callee.
index 0dfb3ae1acc102882ac5f147abb1e1e757efd776..be0bbf58ffa98e21ec5ccfaa983dd2a2487a6576 100644 (file)
@@ -95,4 +95,14 @@ void rdar10308201 (int valA, void *valB, unsigned valC) {
   }
 }
 
+typedef struct Struct103 {
+  unsigned i;
+} Struct103;
+typedef unsigned int size_t;
+void __my_memset_chk(char*, int, size_t);
+static int radar10367606(int t) {
+  Struct103 overall;
+  ((__builtin_object_size ((char *) &overall, 0) != (size_t) -1) ? __builtin___memset_chk ((char *) &overall, 0, sizeof(Struct103), __builtin_object_size ((char *) &overall, 0)) : __my_memset_chk ((char *) &overall, 0, sizeof(Struct103)));
+  return 0;
+}