[cfe-commits] r50233 - in /cfe/trunk: include/clang/Analysis/PathSensitive/GRExprEngine.h include/clang/Analysis/PathSensitive/GRTransferFuncs.h lib/Analysis/GRExprEngine.cpp

Ted Kremenek kremenek at apple.com
Thu Apr 24 16:35:59 PDT 2008


Author: kremenek
Date: Thu Apr 24 18:35:58 2008
New Revision: 50233

URL: http://llvm.org/viewvc/llvm-project?rev=50233&view=rev
Log:
More boilerplate for handling specialized-transfer function logic for dead symbols.

Modified:
    cfe/trunk/include/clang/Analysis/PathSensitive/GRExprEngine.h
    cfe/trunk/include/clang/Analysis/PathSensitive/GRTransferFuncs.h
    cfe/trunk/lib/Analysis/GRExprEngine.cpp

Modified: cfe/trunk/include/clang/Analysis/PathSensitive/GRExprEngine.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/PathSensitive/GRExprEngine.h?rev=50233&r1=50232&r2=50233&view=diff

==============================================================================
--- cfe/trunk/include/clang/Analysis/PathSensitive/GRExprEngine.h (original)
+++ cfe/trunk/include/clang/Analysis/PathSensitive/GRExprEngine.h Thu Apr 24 18:35:58 2008
@@ -78,12 +78,12 @@
   /// SymMgr - Object that manages the symbol information.
   SymbolManager& SymMgr;
   
-  /// StmtEntryNode - The immediate predecessor node.
-  NodeTy* StmtEntryNode;
-  
-  /// CleanedState - The state for StmtEntryNode "cleaned" of all dead
+  /// EntryNode - The immediate predecessor node.
+  NodeTy* EntryNode;
+
+  /// CleanedState - The state for EntryNode "cleaned" of all dead
   ///  variables and symbols (as determined by a liveness analysis).
-  ValueState* CleanedState;
+  ValueState* CleanedState;  
   
   /// CurrentStmt - The current block-level statement.
   Stmt* CurrentStmt;
@@ -392,7 +392,7 @@
 protected:
   
   ValueState* GetState(NodeTy* N) {
-    return N == StmtEntryNode ? CleanedState : N->getState();
+    return N == EntryNode ? CleanedState : N->getState();
   }
   
   ValueState* SetRVal(ValueState* St, Expr* Ex, RVal V);

Modified: cfe/trunk/include/clang/Analysis/PathSensitive/GRTransferFuncs.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/PathSensitive/GRTransferFuncs.h?rev=50233&r1=50232&r2=50233&view=diff

==============================================================================
--- cfe/trunk/include/clang/Analysis/PathSensitive/GRTransferFuncs.h (original)
+++ cfe/trunk/include/clang/Analysis/PathSensitive/GRTransferFuncs.h Thu Apr 24 18:35:58 2008
@@ -84,11 +84,19 @@
                          ValueState* St, RVal TargetLV, RVal Val);
                          
   
-  // End-of-path.
+  // End-of-path and dead symbol notification.
   
   virtual void EvalEndPath(GRExprEngine& Engine,
                            GREndPathNodeBuilder<ValueState>& Builder) {}
   
+  
+  virtual void EvalDeadSymbols(ExplodedNodeSet<ValueState>& Dst,
+                               GRExprEngine& Engine,
+                               GRStmtNodeBuilder<ValueState>& Builder,
+                               ProgramPoint P, ExplodedNode<ValueState>* Pred,
+                               ValueState* St,
+                               const ValueStateManager::DeadSymbolsTy& Dead) {}
+  
   // Return statements.
   
   virtual void EvalReturn(ExplodedNodeSet<ValueState>& Dst,

Modified: cfe/trunk/lib/Analysis/GRExprEngine.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/GRExprEngine.cpp?rev=50233&r1=50232&r2=50233&view=diff

==============================================================================
--- cfe/trunk/lib/Analysis/GRExprEngine.cpp (original)
+++ cfe/trunk/lib/Analysis/GRExprEngine.cpp Thu Apr 24 18:35:58 2008
@@ -42,7 +42,7 @@
     BasicVals(StateMgr.getBasicValueFactory()),
     TF(NULL), // FIXME
     SymMgr(StateMgr.getSymbolManager()),
-    StmtEntryNode(NULL), CleanedState(NULL), CurrentStmt(NULL) {
+    CurrentStmt(NULL) {
   
   // Compute liveness information.
   Liveness.runOnCFG(G.getCFG());
@@ -167,9 +167,8 @@
 void GRExprEngine::ProcessStmt(Stmt* S, StmtNodeBuilder& builder) {
   
   Builder = &builder;
-  StmtEntryNode = builder.getLastNode();
+  EntryNode = builder.getLastNode();
   CurrentStmt = S;
-  NodeSet Dst;
   
   // Set up our simple checks.
   
@@ -187,49 +186,53 @@
   
   // Create the cleaned state.
   
-  CleanedState = StateMgr.RemoveDeadBindings(StmtEntryNode->getState(),
-                                             CurrentStmt, Liveness,
-                                             DeadSymbols);
+  CleanedState = StateMgr.RemoveDeadBindings(EntryNode->getState(), CurrentStmt,
+                                             Liveness, DeadSymbols);
   
   // Process any special transfer function for dead symbols.
   
   NodeSet Tmp;
   
   if (DeadSymbols.empty())
-    Tmp.Add(StmtEntryNode);
+    Tmp.Add(EntryNode);
   else {
     SaveAndRestore<bool> OldSink(Builder->BuildSinks);
-/*      
-    FIXME: Will hook this up next.
- 
-    TF->EvalDeadSymbols(Tmp, *this, *Builder, StmtEntryNode->getLocation(), Pred,
-                        CleanedState, DeadSymbols);
-*/
-    if (!Builder->BuildSinks && Tmp.empty() && !Builder->HasGeneratedNode)
-      Tmp.Add(StmtEntryNode);
+    SaveOr OldHasGen(Builder->HasGeneratedNode);
+
+    TF->EvalDeadSymbols(Tmp, *this, *Builder, EntryNode->getLocation(),
+                        EntryNode, CleanedState, DeadSymbols);
+
+    if (!Builder->BuildSinks && !Builder->HasGeneratedNode)
+      Tmp.Add(EntryNode);
   }
-      
+  
+  bool HasAutoGenerated = false;
+
   for (NodeSet::iterator I=Tmp.begin(), E=Tmp.end(); I!=E; ++I) {
+
+    NodeSet Dst;
+    
     // Set the cleaned state.  
-    Builder->SetCleanedState(*I == StmtEntryNode ? CleanedState : (*I)->getState());
-  
+    Builder->SetCleanedState(*I == EntryNode ? CleanedState : GetState(*I));
+    
     // Visit the statement.  
-    Visit(S, StmtEntryNode, Dst);
+    Visit(S, *I, Dst);
+
+    // Do we need to auto-generate a node?  We only need to do this to generate
+    // a node with a "cleaned" state; GRCoreEngine will actually handle
+    // auto-transitions for other cases.    
+    if (Dst.size() == 1 && *Dst.begin() == EntryNode
+        && !Builder->HasGeneratedNode && !HasAutoGenerated) {
+      HasAutoGenerated = true;
+      builder.generateNode(S, GetState(EntryNode), *I);
+    }
   }
   
-  // If no nodes were generated, generate a new node that has all the
-  // dead mappings removed.
-  
-  if (Dst.size() == 1 && *Dst.begin() == StmtEntryNode && 
-      !Builder->HasGeneratedNode)
-    builder.generateNode(S, GetState(StmtEntryNode), StmtEntryNode);
-  
   // NULL out these variables to cleanup.
-  
+  CleanedState = NULL;
+  EntryNode = NULL;
   CurrentStmt = NULL;
-  StmtEntryNode = NULL;
   Builder = NULL;
-  CleanedState = NULL;
 }
 
 void GRExprEngine::Visit(Stmt* S, NodeTy* Pred, NodeSet& Dst) {





More information about the cfe-commits mailing list