[cfe-commits] r43629 - in /cfe/trunk: Parse/ParseObjc.cpp Sema/Sema.h Sema/SemaStmt.cpp include/clang/Parse/Action.h

Fariborz Jahanian fjahanian at apple.com
Thu Nov 1 17:18:53 PDT 2007


Author: fjahanian
Date: Thu Nov  1 19:18:53 2007
New Revision: 43629

URL: http://llvm.org/viewvc/llvm-project?rev=43629&view=rev
Log:
AST for @finally statement.

Modified:
    cfe/trunk/Parse/ParseObjc.cpp
    cfe/trunk/Sema/Sema.h
    cfe/trunk/Sema/SemaStmt.cpp
    cfe/trunk/include/clang/Parse/Action.h

Modified: cfe/trunk/Parse/ParseObjc.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Parse/ParseObjc.cpp?rev=43629&r1=43628&r2=43629&view=diff

==============================================================================
--- cfe/trunk/Parse/ParseObjc.cpp (original)
+++ cfe/trunk/Parse/ParseObjc.cpp Thu Nov  1 19:18:53 2007
@@ -1055,9 +1055,10 @@
     return true;
   }
   StmtResult CatchStmts;
+  StmtResult FinallyStmt;
   StmtResult TryBody = ParseCompoundStatementBody();
   while (Tok.is(tok::at)) {
-    SourceLocation AtCatchLoc = ConsumeToken();
+    SourceLocation AtCatchFinallyLoc = ConsumeToken();
     if (Tok.getIdentifierInfo()->getObjCKeywordID() == tok::objc_catch) {
       StmtTy *FirstPart = 0;
       ConsumeToken(); // consume catch
@@ -1080,12 +1081,13 @@
         StmtResult CatchBody = ParseCompoundStatementBody();
         if (CatchBody.isInvalid)
           CatchBody = Actions.ActOnNullStmt(Tok.getLocation());
-        CatchStmts = Actions.ActOnObjcAtCatchStmt(AtCatchLoc, RParenLoc, 
+        CatchStmts = Actions.ActOnObjcAtCatchStmt(AtCatchFinallyLoc, RParenLoc, 
           FirstPart, CatchBody.Val, CatchStmts.Val);
         ExitScope();
       }
       else {
-        Diag(AtCatchLoc, diag::err_expected_lparen_after, "@catch clause");
+        Diag(AtCatchFinallyLoc, diag::err_expected_lparen_after, 
+             "@catch clause");
         return true;
       }
       catch_or_finally_seen = true;
@@ -1093,6 +1095,10 @@
     else if (Tok.getIdentifierInfo()->getObjCKeywordID() == tok::objc_finally) {
        ConsumeToken(); // consume finally
       StmtResult FinallyBody = ParseCompoundStatementBody();
+      if (FinallyBody.isInvalid)
+        FinallyBody = Actions.ActOnNullStmt(Tok.getLocation());
+      FinallyStmt = Actions.ActOnObjcAtFinallyStmt(AtCatchFinallyLoc, 
+                                                   FinallyBody.Val);
       catch_or_finally_seen = true;
       break;
     }

Modified: cfe/trunk/Sema/Sema.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Sema/Sema.h?rev=43629&r1=43628&r2=43629&view=diff

==============================================================================
--- cfe/trunk/Sema/Sema.h (original)
+++ cfe/trunk/Sema/Sema.h Thu Nov  1 19:18:53 2007
@@ -343,6 +343,9 @@
                                           SourceLocation RParen, StmtTy *Parm, 
                                           StmtTy *Body, StmtTy *CatchList);
   
+  virtual StmtResult ActOnObjcAtFinallyStmt(SourceLocation AtLoc, 
+                                            StmtTy *Body);
+  
   //===--------------------------------------------------------------------===//
   // Expression Parsing Callbacks: SemaExpr.cpp.
 

Modified: cfe/trunk/Sema/SemaStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Sema/SemaStmt.cpp?rev=43629&r1=43628&r2=43629&view=diff

==============================================================================
--- cfe/trunk/Sema/SemaStmt.cpp (original)
+++ cfe/trunk/Sema/SemaStmt.cpp Thu Nov  1 19:18:53 2007
@@ -659,3 +659,9 @@
   return CatchList ? CatchList : CS;
 }
 
+Action::StmtResult
+Sema::ActOnObjcAtFinallyStmt(SourceLocation AtLoc, StmtTy *Body) {
+  ObjcAtFinallyStmt *FS = new ObjcAtFinallyStmt(AtLoc, 
+                                                static_cast<Stmt*>(Body));
+  return FS;
+}

Modified: cfe/trunk/include/clang/Parse/Action.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Parse/Action.h?rev=43629&r1=43628&r2=43629&view=diff

==============================================================================
--- cfe/trunk/include/clang/Parse/Action.h (original)
+++ cfe/trunk/include/clang/Parse/Action.h Thu Nov  1 19:18:53 2007
@@ -295,6 +295,11 @@
     return 0;
   }
   
+  virtual StmtResult ActOnObjcAtFinallyStmt(SourceLocation AtLoc, 
+                                            StmtTy *Body) {
+    return 0;
+  }
+  
   //===--------------------------------------------------------------------===//
   // Expression Parsing Callbacks.
   //===--------------------------------------------------------------------===//





More information about the cfe-commits mailing list