[cfe-commits] r143516 - in /cfe/trunk: include/clang/StaticAnalyzer/Core/PathSensitive/CoreEngine.h include/clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h lib/StaticAnalyzer/Core/CoreEngine.cpp test/Analysis/misc-ps.c

Anna Zaks ganna at apple.com
Tue Nov 1 15:41:15 PDT 2011


Author: zaks
Date: Tue Nov  1 17:41:14 2011
New Revision: 143516

URL: http://llvm.org/viewvc/llvm-project?rev=143516&view=rev
Log:
[analyzer] Fix PR11282 - an assert in markAsSink

This is another fallout from the refactoring. We were
calling MarkAsSink on a cached out node.
(Fixes radar://10376675)

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

Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/CoreEngine.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/CoreEngine.h?rev=143516&r1=143515&r2=143516&view=diff
==============================================================================
--- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/CoreEngine.h (original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/CoreEngine.h Tue Nov  1 17:41:14 2011
@@ -393,7 +393,7 @@
                     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);
   }

Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h?rev=143516&r1=143515&r2=143516&view=diff
==============================================================================
--- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h (original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h Tue Nov  1 17:41:14 2011
@@ -389,6 +389,7 @@
 
   void clear() { Impl.clear(); }
   void insert(const ExplodedNodeSet &S) {
+    assert(&S != this);
     if (empty())
       Impl = S.Impl;
     else

Modified: cfe/trunk/lib/StaticAnalyzer/Core/CoreEngine.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/CoreEngine.cpp?rev=143516&r1=143515&r2=143516&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Core/CoreEngine.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/CoreEngine.cpp Tue Nov  1 17:41:14 2011
@@ -546,14 +546,17 @@
   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() {

Modified: cfe/trunk/test/Analysis/misc-ps.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/misc-ps.c?rev=143516&r1=143515&r2=143516&view=diff
==============================================================================
--- cfe/trunk/test/Analysis/misc-ps.c (original)
+++ cfe/trunk/test/Analysis/misc-ps.c Tue Nov  1 17:41:14 2011
@@ -106,3 +106,17 @@
   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);
+}





More information about the cfe-commits mailing list