]> granicus.if.org Git - clang/commitdiff
Implemented more boilerplate in GREngine for processing branches. Now
authorTed Kremenek <kremenek@apple.com>
Tue, 29 Jan 2008 23:32:35 +0000 (23:32 +0000)
committerTed Kremenek <kremenek@apple.com>
Tue, 29 Jan 2008 23:32:35 +0000 (23:32 +0000)
we automatically generate a new successor node along an edge if the checker
did not explicitly do so (i.e., we just propagate the current state).

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

Analysis/GRConstants.cpp
Analysis/GREngine.cpp
include/clang/Analysis/PathSensitive/GREngine.h

index 2c6c7f78448871c036b4c1d3ee152532cc4327a4..ad00b608c8870183423ba5e9e0a62e6c400eec51 100644 (file)
@@ -831,8 +831,7 @@ public:
   
   /// ProcessBranch - Called by GREngine.  Used to generate successor
   ///  nodes by processing the 'effects' of a branch condition.
-  void ProcessBranch(Stmt* Condition, Stmt* Term, BranchNodeBuilder& builder)
-  {}
+  void ProcessBranch(Stmt* Condition, Stmt* Term, BranchNodeBuilder& builder);
 
   /// RemoveDeadBindings - Return a new state that is the same as 'M' except
   ///  that all subexpression mappings are removed and that any
@@ -877,6 +876,12 @@ public:
 } // end anonymous namespace
 
 
+void GRConstants::ProcessBranch(Stmt* Condition, Stmt* Term,
+                                BranchNodeBuilder& builder) {
+  
+  
+}
+
 void GRConstants::ProcessStmt(Stmt* S, StmtNodeBuilder& builder) {
   Builder = &builder;
 
index 35101a9dea9c979ef4c5137f3b919e6605d9f5c4..43ee864302de474bd2facdc2a66a132563971e58 100644 (file)
@@ -296,6 +296,14 @@ void GRBranchNodeBuilderImpl::generateNodeImpl(void* State, bool branch) {
   
   Succ->addPredecessor(Pred);
   
+  if (branch) GeneratedTrue = true;
+  else GeneratedFalse = true;  
+  
   if (IsNew)
     Eng.WList->Enqueue(GRWorkListUnit(Succ));
 }
+
+GRBranchNodeBuilderImpl::~GRBranchNodeBuilderImpl() {
+  if (!GeneratedTrue) generateNodeImpl(Pred->State, true);
+  if (!GeneratedFalse) generateNodeImpl(Pred->State, false);
+}
index c3a9e209b8cb838c6baa8aa67bbcdfdc4213baf4..175b1fb7ae858e2d76e979fbe87acc5f19956928 100644 (file)
@@ -167,12 +167,16 @@ class GRBranchNodeBuilderImpl {
   CFGBlock* DstF;
   ExplodedNodeImpl* Pred;
   
+  bool GeneratedTrue;
+  bool GeneratedFalse;
+  
 public:
   GRBranchNodeBuilderImpl(CFGBlock* src, CFGBlock* dstT, CFGBlock* dstF,
                           ExplodedNodeImpl* pred, GREngineImpl* e) 
-  : Eng(*e), Src(src), DstT(dstT), DstF(dstF), Pred(pred) {}
+  : Eng(*e), Src(src), DstT(dstT), DstF(dstF), Pred(pred),
+    GeneratedTrue(false), GeneratedFalse(false) {}
   
-  ~GRBranchNodeBuilderImpl() {}
+  ~GRBranchNodeBuilderImpl();
   
   const ExplodedGraphImpl& getGraph() const { return *Eng.G; }