From 2fda504dccd79f91ac9a7d82acecfbab3eaa1719 Mon Sep 17 00:00:00 2001 From: Ted Kremenek Date: Tue, 9 Dec 2008 20:20:09 +0000 Subject: [PATCH] Add preliminary CFG support for @throw. We basically treat it like a return statement. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@60790 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/AST/CFG.cpp | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/lib/AST/CFG.cpp b/lib/AST/CFG.cpp index 69e82f2b83..b84ead763f 100644 --- a/lib/AST/CFG.cpp +++ b/lib/AST/CFG.cpp @@ -132,7 +132,10 @@ public: CFGBlock* VisitObjCAtTryStmt(ObjCAtTryStmt* S) { return NYS(); } CFGBlock* VisitObjCAtCatchStmt(ObjCAtCatchStmt* S) { return NYS(); } CFGBlock* VisitObjCAtFinallyStmt(ObjCAtFinallyStmt* S) { return NYS(); } - CFGBlock* VisitObjCAtThrowStmt(ObjCAtThrowStmt* S) { return NYS(); } + + // FIXME: This is not completely supported. We basically @throw like + // a 'return'. + CFGBlock* VisitObjCAtThrowStmt(ObjCAtThrowStmt* S); CFGBlock* VisitObjCAtSynchronizedStmt(ObjCAtSynchronizedStmt* S){ return NYS(); @@ -972,6 +975,25 @@ CFGBlock* CFGBuilder::VisitWhileStmt(WhileStmt* W) { Succ = EntryConditionBlock; return EntryConditionBlock; } + +CFGBlock* CFGBuilder::VisitObjCAtThrowStmt(ObjCAtThrowStmt* S) { + // FIXME: This isn't complete. We basically treat @throw like a return + // statement. + + // If we were in the middle of a block we stop processing that block + // and reverse its statements. + if (Block) FinishBlock(Block); + + // 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 addStmt(S); +} CFGBlock* CFGBuilder::VisitDoStmt(DoStmt* D) { // "do...while" is a control-flow statement. Thus we stop processing the -- 2.40.0