From: Ted Kremenek Date: Wed, 22 Aug 2007 21:03:50 +0000 (+0000) Subject: Added explicit pointer within class CFG to the Entry block. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=fa2be43dbd6fdc4414e261db69aaf35dfb21a416;p=clang Added explicit pointer within class CFG to the Entry block. Before we assumed that the first block in the list of blocks was the entry block, but this has posed hurdles during CFG construction. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41293 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/AST/CFG.h b/include/clang/AST/CFG.h index 0f26a8dcbf..8cfe545529 100644 --- a/include/clang/AST/CFG.h +++ b/include/clang/AST/CFG.h @@ -153,11 +153,11 @@ public: /// was constructed from. class CFG { typedef std::list CFGBlockListTy; + CFGBlock* Entry; CFGBlockListTy Blocks; - + public: - - CFG() {}; + CFG() : Entry(NULL) {}; ~CFG() {}; CFGBlock* createBlock(unsigned blockID) { @@ -171,28 +171,28 @@ public: typedef std::reverse_iterator reverse_iterator; typedef std::reverse_iterator const_reverse_iterator; - CFGBlock& front() { return Blocks.front(); } - CFGBlock& back() { return Blocks.back(); } + CFGBlock& front() { return Blocks.front(); } + CFGBlock& back() { return Blocks.back(); } - iterator begin() { return Blocks.begin(); } - iterator end() { return Blocks.end(); } - const_iterator begin() const { return Blocks.begin(); } - const_iterator end() const { return Blocks.end(); } + iterator begin() { return Blocks.begin(); } + iterator end() { return Blocks.end(); } + const_iterator begin() const { return Blocks.begin(); } + const_iterator end() const { return Blocks.end(); } - reverse_iterator rbegin() { return Blocks.rbegin(); } - reverse_iterator rend() { return Blocks.rend(); } - const_reverse_iterator rbegin() const { return Blocks.rbegin(); } - const_reverse_iterator rend() const { return Blocks.rend(); } + reverse_iterator rbegin() { return Blocks.rbegin(); } + reverse_iterator rend() { return Blocks.rend(); } + const_reverse_iterator rbegin() const { return Blocks.rbegin(); } + const_reverse_iterator rend() const { return Blocks.rend(); } - CFGBlock& getEntry() { return front(); } - CFGBlock& getExit() { return back(); } + CFGBlock& getEntry() { return Entry ? *Entry : front(); } + CFGBlock& getExit() { return back(); } // Utility static CFG* BuildCFG(Stmt* AST); void print(std::ostream& OS); void dump(); - + void setEntry(CFGBlock *B) { Entry = B; } }; -} // end namespace clang \ No newline at end of file +} // end namespace clang