This patch 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 generate a
new ExplodedNode but not a new block edge.

This patch is preparation for statistical UncheckedRenturn checker.

I'll appreciate it if there are any advice about this patch.

-- 
Best regards!

Lei Zhang
Index: include/clang/Analysis/ProgramPoint.h
===================================================================
--- include/clang/Analysis/ProgramPoint.h	(revision 128522)
+++ include/clang/Analysis/ProgramPoint.h	(working copy)
@@ -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,
Index: lib/StaticAnalyzer/Core/CoreEngine.cpp
===================================================================
--- lib/StaticAnalyzer/Core/CoreEngine.cpp	(revision 128522)
+++ lib/StaticAnalyzer/Core/CoreEngine.cpp	(working copy)
@@ -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) {
 
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to