]> granicus.if.org Git - clang/commitdiff
static analyzer: Add a new ProgramPoint PostCondition to represent the post position...
authorTed Kremenek <kremenek@apple.com>
Sun, 3 Apr 2011 04:34:49 +0000 (04:34 +0000)
committerTed Kremenek <kremenek@apple.com>
Sun, 3 Apr 2011 04:34:49 +0000 (04:34 +0000)
Patch by Lei Zhang!

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

include/clang/Analysis/ProgramPoint.h
include/clang/StaticAnalyzer/Core/PathSensitive/CoreEngine.h
lib/StaticAnalyzer/Core/CoreEngine.cpp

index 54cfc3dc0db6a1b0d462a8738e4f5d310bf1ab69..07b4dea987ded03a97eee3527a0dda4307098251 100644 (file)
@@ -43,6 +43,7 @@ public:
               PostStoreKind,
               PostPurgeDeadSymbolsKind,
               PostStmtCustomKind,
+              PostConditionKind,
               PostLValueKind,
               PostInitializerKind,
               CallEnterKind,
@@ -221,7 +222,17 @@ public:
   }
 };
 
-  
+// 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,
index 41d7b9eafdd3bc1fe8728e4a3edee17cf6b893be..9b1402fb3eb09a0b434bb8352e557c456b04c0e2 100644 (file)
@@ -307,6 +307,8 @@ public:
 
   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 {
index 73709e39d0d0b6b250f7f740bf278afb12ecff16..a161f652a62fb8dac69d9f4ab3bc02b1b284c7eb 100644 (file)
@@ -602,6 +602,25 @@ StmtNodeBuilder::generateNodeInternal(const ProgramPoint &Loc,
   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) {