[cfe-commits] r128784 - in /cfe/trunk: include/clang/Analysis/ProgramPoint.h include/clang/StaticAnalyzer/Core/PathSensitive/CoreEngine.h lib/StaticAnalyzer/Core/CoreEngine.cpp

Ted Kremenek kremenek at apple.com
Sat Apr 2 21:34:49 PDT 2011


Author: kremenek
Date: Sat Apr  2 23:34:49 2011
New Revision: 128784

URL: http://llvm.org/viewvc/llvm-project?rev=128784&view=rev
Log:
static analyzer: Add a new ProgramPoint PostCondition to represent the post position of a branch condition, and a new generateNode method to BranchNodeBuilder using PostCondition ProgramPoint. This method generates a new ExplodedNode but not a new block edge.

Patch by Lei Zhang!

Modified:
    cfe/trunk/include/clang/Analysis/ProgramPoint.h
    cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/CoreEngine.h
    cfe/trunk/lib/StaticAnalyzer/Core/CoreEngine.cpp

Modified: cfe/trunk/include/clang/Analysis/ProgramPoint.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/ProgramPoint.h?rev=128784&r1=128783&r2=128784&view=diff
==============================================================================
--- cfe/trunk/include/clang/Analysis/ProgramPoint.h (original)
+++ cfe/trunk/include/clang/Analysis/ProgramPoint.h Sat Apr  2 23:34:49 2011
@@ -43,6 +43,7 @@
               PostStoreKind,
               PostPurgeDeadSymbolsKind,
               PostStmtCustomKind,
+              PostConditionKind,
               PostLValueKind,
               PostInitializerKind,
               CallEnterKind,
@@ -221,7 +222,17 @@
   }
 };
 
-  
+// PostCondition represents the post program point of a branch condition.
+class PostCondition : public PostStmt {
+public:
+  PostCondition(const Stmt* S, const LocationContext *L, const void *tag = 0)
+    : PostStmt(S, PostConditionKind, L, tag) {}
+
+  static bool classof(const ProgramPoint* Location) {
+    return Location->getKind() == PostConditionKind;
+  }
+};
+
 class LocationCheck : public StmtPoint {
 protected:
   LocationCheck(const Stmt *S, const LocationContext *L,

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=128784&r1=128783&r2=128784&view=diff
==============================================================================
--- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/CoreEngine.h (original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/CoreEngine.h Sat Apr  2 23:34:49 2011
@@ -307,6 +307,8 @@
 
   BlockCounter getBlockCounter() const { return Eng.WList->getBlockCounter();}
 
+  ExplodedNode* generateNode(const Stmt *Condition, const GRState* State);
+
   ExplodedNode* generateNode(const GRState* State, bool branch);
 
   const CFGBlock* getTargetBlock(bool branch) const {

Modified: cfe/trunk/lib/StaticAnalyzer/Core/CoreEngine.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/CoreEngine.cpp?rev=128784&r1=128783&r2=128784&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Core/CoreEngine.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/CoreEngine.cpp Sat Apr  2 23:34:49 2011
@@ -602,6 +602,25 @@
   return NULL;
 }
 
+// This function generate a new ExplodedNode but not a new branch(block edge).
+ExplodedNode* BranchNodeBuilder::generateNode(const Stmt* Condition,
+                                              const GRState* State) {
+  bool IsNew;
+  
+  ExplodedNode* Succ 
+    = Eng.G->getNode(PostCondition(Condition, Pred->getLocationContext()), State,
+                     &IsNew);
+  
+  Succ->addPredecessor(Pred, *Eng.G);
+  
+  Pred = Succ;
+  
+  if (IsNew) 
+    return Succ;
+  
+  return NULL;
+}
+
 ExplodedNode* BranchNodeBuilder::generateNode(const GRState* State,
                                                 bool branch) {
 





More information about the cfe-commits mailing list