summaryrefslogtreecommitdiffstats
path: root/clang/lib/Analysis
diff options
context:
space:
mode:
authorMike Stump <mrs@apple.com>2009-07-22 22:56:04 +0000
committerMike Stump <mrs@apple.com>2009-07-22 22:56:04 +0000
commit8dd1b6bd1067449e01d25d1ae909119e514941f5 (patch)
tree0113688e42ff2d5a94f38cfa1ae4c46ef12557ef /clang/lib/Analysis
parent24cbfc370b2b3ef026ebaf94f3fee08a730724e2 (diff)
downloadbcm5719-llvm-8dd1b6bd1067449e01d25d1ae909119e514941f5.tar.gz
bcm5719-llvm-8dd1b6bd1067449e01d25d1ae909119e514941f5.zip
Improve CFG support for C++ throw expressions.
llvm-svn: 76814
Diffstat (limited to 'clang/lib/Analysis')
-rw-r--r--clang/lib/Analysis/CFG.cpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/clang/lib/Analysis/CFG.cpp b/clang/lib/Analysis/CFG.cpp
index 4c2ecb92f60..f43631c4d0a 100644
--- a/clang/lib/Analysis/CFG.cpp
+++ b/clang/lib/Analysis/CFG.cpp
@@ -99,6 +99,7 @@ private:
CFGBlock *VisitCompoundStmt(CompoundStmt *C);
CFGBlock *VisitConditionalOperator(ConditionalOperator *C);
CFGBlock *VisitContinueStmt(ContinueStmt *C);
+ CFGBlock *VisitCXXThrowExpr(CXXThrowExpr *T);
CFGBlock *VisitDeclStmt(DeclStmt *DS);
CFGBlock *VisitDeclSubExpr(Decl* D);
CFGBlock *VisitDefaultStmt(DefaultStmt *D);
@@ -319,6 +320,9 @@ tryAgain:
case Stmt::ObjCAtCatchStmtClass:
return VisitObjCAtCatchStmt(cast<ObjCAtCatchStmt>(S));
+ case Stmt::CXXThrowExprClass:
+ return VisitCXXThrowExpr(cast<CXXThrowExpr>(S));
+
case Stmt::ObjCAtSynchronizedStmtClass:
return VisitObjCAtSynchronizedStmt(cast<ObjCAtSynchronizedStmt>(S));
@@ -1262,6 +1266,23 @@ CFGBlock* CFGBuilder::VisitObjCAtThrowStmt(ObjCAtThrowStmt* S) {
return VisitStmt(S, true);
}
+CFGBlock* CFGBuilder::VisitCXXThrowExpr(CXXThrowExpr* T) {
+ // If we were in the middle of a block we stop processing that block and
+ // reverse its statements.
+ if (Block && !FinishBlock(Block))
+ return 0;
+
+ // Create the new block.
+ Block = createBlock(false);
+
+ // The Exit block is the only successor.
+ Block->addSuccessor(&cfg->getExit());
+
+ // Add the statement to the block. This may create new blocks if S contains
+ // control-flow (short-circuit operations).
+ return VisitStmt(T, true);
+}
+
CFGBlock *CFGBuilder::VisitDoStmt(DoStmt* D) {
// See if this is a known constant.
bool KnownTrue = false;
OpenPOWER on IntegriCloud