[cfe-commits] r41724 - in /cfe/trunk: AST/CFG.cpp include/clang/AST/CFG.h

Ted Kremenek kremenek at apple.com
Wed Sep 5 13:02:06 PDT 2007


Author: kremenek
Date: Wed Sep  5 15:02:05 2007
New Revision: 41724

URL: http://llvm.org/viewvc/llvm-project?rev=41724&view=rev
Log:
Moved tracking of CFG block IDs into the CFG class.
Added CFG::getNumBlockIDs() to query the number of distinct block ids created.

Modified:
    cfe/trunk/AST/CFG.cpp
    cfe/trunk/include/clang/AST/CFG.h

Modified: cfe/trunk/AST/CFG.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/AST/CFG.cpp?rev=41724&r1=41723&r2=41724&view=diff

==============================================================================
--- cfe/trunk/AST/CFG.cpp (original)
+++ cfe/trunk/AST/CFG.cpp Wed Sep  5 15:02:05 2007
@@ -63,7 +63,6 @@
   CFGBlock* ContinueTargetBlock;
   CFGBlock* BreakTargetBlock;
   CFGBlock* SwitchTerminatedBlock;
-  unsigned NumBlocks;
   
   // LabelMap records the mapping from Label expressions to their blocks.
   typedef llvm::DenseMap<LabelStmt*,CFGBlock*> LabelMapTy;
@@ -81,8 +80,7 @@
 public:  
   explicit CFGBuilder() : cfg(NULL), Block(NULL), Succ(NULL),
                           ContinueTargetBlock(NULL), BreakTargetBlock(NULL),
-                          SwitchTerminatedBlock(NULL),
-                          NumBlocks(0) {
+                          SwitchTerminatedBlock(NULL) {
     // Create an empty CFG.
     cfg = new CFG();                        
   }
@@ -194,7 +192,7 @@
 /// createBlock - Used to lazily create blocks that are connected
 ///  to the current (global) succcessor.
 CFGBlock* CFGBuilder::createBlock(bool add_successor) { 
-  CFGBlock* B = cfg->createBlock(NumBlocks++);
+  CFGBlock* B = cfg->createBlock();
   if (add_successor && Succ) B->addSuccessor(Succ);
   return B;
 }
@@ -894,11 +892,11 @@
 ///  block has no successors or predecessors.  If this is the first block
 ///  created in the CFG, it is automatically set to be the Entry and Exit
 ///  of the CFG.
-CFGBlock* CFG::createBlock(unsigned blockID) {
+CFGBlock* CFG::createBlock() {
   bool first_block = begin() == end();
 
   // Create the block.
-  Blocks.push_front(CFGBlock(blockID));
+  Blocks.push_front(CFGBlock(NumBlockIDs++));
 
   // If this is the first block, set it as the Entry and Exit.
   if (first_block) Entry = Exit = &front();

Modified: cfe/trunk/include/clang/AST/CFG.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/CFG.h?rev=41724&r1=41723&r2=41724&view=diff

==============================================================================
--- cfe/trunk/include/clang/AST/CFG.h (original)
+++ cfe/trunk/include/clang/AST/CFG.h Wed Sep  5 15:02:05 2007
@@ -179,9 +179,10 @@
   CFGBlock* IndirectGotoBlock;  // Special block to contain collective dispatch
                                 // for indirect gotos
   CFGBlockListTy Blocks;
+  unsigned NumBlockIDs;
   
 public:
-  CFG() : Entry(NULL), Exit(NULL), IndirectGotoBlock(NULL) {};
+  CFG() : Entry(NULL), Exit(NULL), IndirectGotoBlock(NULL), NumBlockIDs(0) {};
   ~CFG() {};
   
   // Block iterators
@@ -213,7 +214,9 @@
   
   // Utility
   
-  CFGBlock* createBlock(unsigned blockID);
+  CFGBlock* createBlock();
+  unsigned getNumBlockIDs() const { return NumBlockIDs; }
+  
   static CFG* buildCFG(Stmt* AST);
   void viewCFG() const;
   void print(std::ostream& OS) const;





More information about the cfe-commits mailing list