[cfe-commits] r60790 - /cfe/trunk/lib/AST/CFG.cpp

Ted Kremenek kremenek at apple.com
Tue Dec 9 12:20:10 PST 2008


Author: kremenek
Date: Tue Dec  9 14:20:09 2008
New Revision: 60790

URL: http://llvm.org/viewvc/llvm-project?rev=60790&view=rev
Log:
Add preliminary CFG support for @throw.  We basically treat it like a return statement.

Modified:
    cfe/trunk/lib/AST/CFG.cpp

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

==============================================================================
--- cfe/trunk/lib/AST/CFG.cpp (original)
+++ cfe/trunk/lib/AST/CFG.cpp Tue Dec  9 14:20:09 2008
@@ -132,7 +132,10 @@
   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 @@
   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





More information about the cfe-commits mailing list