[cfe-commits] r139593 - in /cfe/trunk: include/clang/Analysis/CFG.h lib/Analysis/CFG.cpp
Chandler Carruth
chandlerc at gmail.com
Tue Sep 13 02:53:55 PDT 2011
Author: chandlerc
Date: Tue Sep 13 04:53:55 2011
New Revision: 139593
URL: http://llvm.org/viewvc/llvm-project?rev=139593&view=rev
Log:
Add a bit to the CFGBlock to track when it contains a no-return
CFGElement. This will allow greatly simplifying the logic in
-Wreturn-type.
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=139593&r1=139592&r2=139593&view=diff
==============================================================================
--- cfe/trunk/include/clang/Analysis/CFG.h (original)
+++ cfe/trunk/include/clang/Analysis/CFG.h Tue Sep 13 04:53:55 2011
@@ -333,10 +333,21 @@
AdjacentBlocks Preds;
AdjacentBlocks Succs;
+ /// NoReturn - This bit is set when the basic block contains a function call
+ /// or implicit destructor that is attributed as 'noreturn'. In that case,
+ /// control cannot technically ever proceed past this block. All such blocks
+ /// will have a single immediate successor: the exit block. This allows them
+ /// to be easily reached from the exit block and using this bit quickly
+ /// recognized without scanning the contents of the block.
+ ///
+ /// Optimization Note: This bit could be profitably folded with Terminator's
+ /// storage if the memory usage of CFGBlock becomes an issue.
+ unsigned HasNoReturnElement : 1;
+
public:
explicit CFGBlock(unsigned blockid, BumpVectorContext &C)
: Elements(C), Label(NULL), Terminator(NULL), LoopTarget(NULL),
- BlockID(blockid), Preds(C, 1), Succs(C, 1) {}
+ BlockID(blockid), Preds(C, 1), Succs(C, 1), HasNoReturnElement(false) {}
~CFGBlock() {}
// Statement iterators
@@ -458,6 +469,7 @@
void setTerminator(Stmt *Statement) { Terminator = Statement; }
void setLabel(Stmt *Statement) { Label = Statement; }
void setLoopTarget(const Stmt *loopTarget) { LoopTarget = loopTarget; }
+ void setHasNoReturnElement() { HasNoReturnElement = true; }
CFGTerminator getTerminator() { return Terminator; }
const CFGTerminator getTerminator() const { return Terminator; }
@@ -473,6 +485,8 @@
Stmt *getLabel() { return Label; }
const Stmt *getLabel() const { return Label; }
+ bool hasNoReturnElement() const { return HasNoReturnElement; }
+
unsigned getBlockID() const { return BlockID; }
void dump(const CFG *cfg, const LangOptions &LO) const;
Modified: cfe/trunk/lib/Analysis/CFG.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/CFG.cpp?rev=139593&r1=139592&r2=139593&view=diff
==============================================================================
--- cfe/trunk/lib/Analysis/CFG.cpp (original)
+++ cfe/trunk/lib/Analysis/CFG.cpp Tue Sep 13 04:53:55 2011
@@ -603,6 +603,7 @@
/// directly tied to the exit block in order to be reachable.
CFGBlock *CFGBuilder::createNoReturnBlock() {
CFGBlock *B = createBlock(false);
+ B->setHasNoReturnElement();
addSuccessor(B, &cfg->getExit());
return B;
}
More information about the cfe-commits
mailing list