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

Fariborz Jahanian fjahanian at apple.com
Fri Nov 2 08:39:35 PDT 2007


Author: fjahanian
Date: Fri Nov  2 10:39:31 2007
New Revision: 43640

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

Modified:
    cfe/trunk/Parse/ParseObjc.cpp
    cfe/trunk/Sema/Sema.h
    cfe/trunk/Sema/SemaStmt.cpp
    cfe/trunk/include/clang/AST/Stmt.h
    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=43640&r1=43639&r2=43640&view=diff

==============================================================================
--- cfe/trunk/Parse/ParseObjc.cpp (original)
+++ cfe/trunk/Parse/ParseObjc.cpp Fri Nov  2 10:39:31 2007
@@ -1057,6 +1057,8 @@
   StmtResult CatchStmts;
   StmtResult FinallyStmt;
   StmtResult TryBody = ParseCompoundStatementBody();
+  if (TryBody.isInvalid)
+    TryBody = Actions.ActOnNullStmt(Tok.getLocation());
   while (Tok.is(tok::at)) {
     SourceLocation AtCatchFinallyLoc = ConsumeToken();
     if (Tok.getIdentifierInfo()->getObjCKeywordID() == tok::objc_catch) {
@@ -1103,9 +1105,12 @@
       break;
     }
   }
-  if (!catch_or_finally_seen)
+  if (!catch_or_finally_seen) {
     Diag(atLoc, diag::err_missing_catch_finally);
-  return true;
+    return true;
+  }
+  return Actions.ActOnObjcAtTryStmt(atLoc, TryBody.Val, CatchStmts.Val, 
+                                    FinallyStmt.Val);
 }
 
 ///   objc-method-def: objc-method-proto ';'[opt] '{' body '}'

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

==============================================================================
--- cfe/trunk/Sema/Sema.h (original)
+++ cfe/trunk/Sema/Sema.h Fri Nov  2 10:39:31 2007
@@ -346,6 +346,10 @@
   virtual StmtResult ActOnObjcAtFinallyStmt(SourceLocation AtLoc, 
                                             StmtTy *Body);
   
+  virtual StmtResult ActOnObjcAtTryStmt(SourceLocation AtLoc, 
+                                        StmtTy *Try, 
+                                        StmtTy *Catch, StmtTy *Finally);
+  
   //===--------------------------------------------------------------------===//
   // Expression Parsing Callbacks: SemaExpr.cpp.
 

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

==============================================================================
--- cfe/trunk/Sema/SemaStmt.cpp (original)
+++ cfe/trunk/Sema/SemaStmt.cpp Fri Nov  2 10:39:31 2007
@@ -665,3 +665,16 @@
                                                 static_cast<Stmt*>(Body));
   return FS;
 }
+
+Action::StmtResult
+Sema::ActOnObjcAtTryStmt(SourceLocation AtLoc, 
+                         StmtTy *Try, StmtTy *Catch, StmtTy *Finally) {
+  ObjcAtTryStmt *TS = new ObjcAtTryStmt(AtLoc, static_cast<Stmt*>(Try), 
+                                        static_cast<Stmt*>(Catch), 
+                                        static_cast<Stmt*>(Finally));
+  return TS;
+}
+
+
+
+

Modified: cfe/trunk/include/clang/AST/Stmt.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Stmt.h?rev=43640&r1=43639&r2=43640&view=diff

==============================================================================
--- cfe/trunk/include/clang/AST/Stmt.h (original)
+++ cfe/trunk/include/clang/AST/Stmt.h Fri Nov  2 10:39:31 2007
@@ -736,8 +736,8 @@
       
 public:
   ObjcAtTryStmt(SourceLocation atTryLoc, Stmt *atTryStmt, 
-                ObjcAtCatchStmt *atCatchStmt, 
-                ObjcAtFinallyStmt *atFinallyStmt)
+                Stmt *atCatchStmt, 
+                Stmt *atFinallyStmt)
   : Stmt(ObjcAtTryStmtClass), AtTryLoc(atTryLoc) {
       SubStmts[TRY] = atTryStmt;
       SubStmts[CATCH] = atCatchStmt;

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

==============================================================================
--- cfe/trunk/include/clang/Parse/Action.h (original)
+++ cfe/trunk/include/clang/Parse/Action.h Fri Nov  2 10:39:31 2007
@@ -300,6 +300,11 @@
     return 0;
   }
   
+  virtual StmtResult ActOnObjcAtTryStmt(SourceLocation AtLoc, 
+                                        StmtTy *Try, 
+                                        StmtTy *Catch, StmtTy *Finally) {
+    return 0;
+  }
   //===--------------------------------------------------------------------===//
   // Expression Parsing Callbacks.
   //===--------------------------------------------------------------------===//





More information about the cfe-commits mailing list