[cfe-commits] r113798 - in /cfe/trunk: include/clang/Analysis/CFG.h lib/Analysis/CFG.cpp

Ted Kremenek kremenek at apple.com
Mon Sep 13 15:25:54 PDT 2010


Author: kremenek
Date: Mon Sep 13 17:25:54 2010
New Revision: 113798

URL: http://llvm.org/viewvc/llvm-project?rev=113798&view=rev
Log:
Remove from the CFG the half-implemented support for scoping information.  We decided that scope information doesn't belong in the CFG at all, since it is a lexical construct.

Patch by Marcin Świderski!

Modified:
    cfe/trunk/include/clang/Analysis/CFG.h
    cfe/trunk/lib/Analysis/CFG.cpp

Modified: cfe/trunk/include/clang/Analysis/CFG.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/CFG.h?rev=113798&r1=113797&r2=113798&view=diff
==============================================================================
--- cfe/trunk/include/clang/Analysis/CFG.h (original)
+++ cfe/trunk/include/clang/Analysis/CFG.h Mon Sep 13 17:25:54 2010
@@ -294,12 +294,6 @@
   
   void appendStmt(Stmt* Statement, BumpVectorContext &C, bool asLValue) {
       Stmts.push_back(CFGElement(Statement, asLValue), C);
-  }  
-  void StartScope(Stmt* S, BumpVectorContext &C) {
-    Stmts.push_back(CFGElement(S, CFGElement::StartScope), C);
-  }
-  void EndScope(Stmt* S, BumpVectorContext &C) {
-    Stmts.push_back(CFGElement(S, CFGElement::EndScope), C);
   }
 };
 
@@ -321,9 +315,7 @@
   ///   constructed CFG belongs to the caller.
   static CFG* buildCFG(const Decl *D, Stmt* AST, ASTContext *C,
                        bool pruneTriviallyFalseEdges = true,
-                       bool AddEHEdges = false,
-                       bool AddScopes = false /* NOT FULLY IMPLEMENTED.
-                                                 NOT READY FOR GENERAL USE. */);
+                       bool AddEHEdges = false);
 
   /// createBlock - Create a new block in the CFG.  The CFG owns the block;
   ///  the caller should not directly free it.

Modified: cfe/trunk/lib/Analysis/CFG.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/CFG.cpp?rev=113798&r1=113797&r2=113798&view=diff
==============================================================================
--- cfe/trunk/lib/Analysis/CFG.cpp (original)
+++ cfe/trunk/lib/Analysis/CFG.cpp Mon Sep 13 17:25:54 2010
@@ -100,8 +100,7 @@
 
   // buildCFG - Used by external clients to construct the CFG.
   CFG* buildCFG(const Decl *D, Stmt *Statement, ASTContext *C,
-                bool pruneTriviallyFalseEdges, bool AddEHEdges,
-                bool AddScopes);
+                bool pruneTriviallyFalseEdges, bool AddEHEdges);
 
 private:
   // Visitors to walk an AST and construct the CFG.
@@ -150,25 +149,6 @@
     return Block;
   }
 
-  CFGBlock *StartScope(Stmt *S, CFGBlock *B) {
-    if (!AddScopes)
-      return B;
-
-    if (B == 0)
-      B = createBlock();
-    B->StartScope(S, cfg->getBumpVectorContext());
-    return B;
-  }
-
-  void EndScope(Stmt *S) {
-    if (!AddScopes)
-      return;
-
-    if (Block == 0)
-      Block = createBlock();
-    Block->EndScope(S, cfg->getBumpVectorContext());
-  }
-
   void autoCreateBlock() { if (!Block) Block = createBlock(); }
   CFGBlock *createBlock(bool add_successor = true);
 
@@ -225,9 +205,6 @@
 
   // True iff EH edges on CallExprs should be added to the CFG.
   bool AddEHEdges;
-
-  // True iff scope start and scope end notes should be added to the CFG.
-  bool AddScopes;
 };
 
 // FIXME: Add support for dependent-sized array types in C++?
@@ -251,7 +228,7 @@
 ///  NULL.
 CFG* CFGBuilder::buildCFG(const Decl *D, Stmt* Statement, ASTContext* C,
                           bool pruneTriviallyFalseEdges,
-                          bool addehedges, bool AddScopes) {
+                          bool addehedges) {
 
   AddEHEdges = addehedges;
   PruneTriviallyFalseEdges = pruneTriviallyFalseEdges;
@@ -261,7 +238,6 @@
   if (!Statement)
     return NULL;
 
-  this->AddScopes = AddScopes;
   badCFG = false;
 
   // Create an empty block that will serve as the exit block for the CFG.  Since
@@ -690,8 +666,6 @@
 
 
 CFGBlock* CFGBuilder::VisitCompoundStmt(CompoundStmt* C) {
-  EndScope(C);
-
   CFGBlock* LastBlock = Block;
 
   for (CompoundStmt::reverse_body_iterator I=C->body_rbegin(), E=C->body_rend();
@@ -705,8 +679,6 @@
       return NULL;
   }
 
-  LastBlock = StartScope(C, LastBlock);
-
   return LastBlock;
 }
 
@@ -1835,10 +1807,10 @@
 ///  CFG is returned to the caller.
 CFG* CFG::buildCFG(const Decl *D, Stmt* Statement, ASTContext *C,
                    bool PruneTriviallyFalse,
-                   bool AddEHEdges, bool AddScopes) {
+                   bool AddEHEdges) {
   CFGBuilder Builder;
   return Builder.buildCFG(D, Statement, C, PruneTriviallyFalse,
-                          AddEHEdges, AddScopes);
+                          AddEHEdges);
 }
 
 //===----------------------------------------------------------------------===//
@@ -2121,16 +2093,6 @@
 
 static void print_stmt(llvm::raw_ostream &OS, StmtPrinterHelper* Helper,
                        const CFGElement &E) {
-
-  if (E.asStartScope()) {
-    OS << "start scope\n";
-    return;
-  }
-  if (E.asEndScope()) {
-    OS << "end scope\n";
-    return;
-  }
-
   Stmt *S = E;
   
   if (Helper) {





More information about the cfe-commits mailing list