[cfe-commits] r62465 - in /cfe/trunk: Driver/PrintParserCallbacks.cpp include/clang/Parse/Action.h lib/Parse/ParseObjc.cpp lib/Sema/Sema.h lib/Sema/SemaStmt.cpp

Sebastian Redl sebastian.redl at getdesigned.at
Sun Jan 18 09:43:12 PST 2009


Author: cornedbee
Date: Sun Jan 18 11:43:11 2009
New Revision: 62465

URL: http://llvm.org/viewvc/llvm-project?rev=62465&view=rev
Log:
Convert ObjC statement actions to smart pointers.

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

Modified: cfe/trunk/Driver/PrintParserCallbacks.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/PrintParserCallbacks.cpp?rev=62465&r1=62464&r2=62465&view=diff

==============================================================================
--- cfe/trunk/Driver/PrintParserCallbacks.cpp (original)
+++ cfe/trunk/Driver/PrintParserCallbacks.cpp Sun Jan 18 11:43:11 2009
@@ -381,37 +381,38 @@
     }
 
     // Objective-c statements
-    virtual StmtResult ActOnObjCAtCatchStmt(SourceLocation AtLoc, 
-                                            SourceLocation RParen, StmtTy *Parm, 
-                                            StmtTy *Body, StmtTy *CatchList) {
+    virtual OwningStmtResult ActOnObjCAtCatchStmt(SourceLocation AtLoc,
+                                                  SourceLocation RParen,
+                                                  StmtArg Parm, StmtArg Body,
+                                                  StmtArg CatchList) {
       llvm::cout << __FUNCTION__ << "\n";
-      return 0;
+      return StmtEmpty();
     }
-  
-    virtual StmtResult ActOnObjCAtFinallyStmt(SourceLocation AtLoc, 
-                                              StmtTy *Body) {
+
+    virtual OwningStmtResult ActOnObjCAtFinallyStmt(SourceLocation AtLoc,
+                                                    StmtArg Body) {
       llvm::cout << __FUNCTION__ << "\n";
-      return 0;
+      return StmtEmpty();
     }
-  
-    virtual StmtResult ActOnObjCAtTryStmt(SourceLocation AtLoc, 
-                                          StmtTy *Try, 
-                                          StmtTy *Catch, StmtTy *Finally) {
+
+    virtual OwningStmtResult ActOnObjCAtTryStmt(SourceLocation AtLoc,
+                                                StmtArg Try, StmtArg Catch,
+                                                StmtArg Finally) {
       llvm::cout << __FUNCTION__ << "\n";
-      return 0;
+      return StmtEmpty();
     }
-  
-    virtual StmtResult ActOnObjCAtThrowStmt(SourceLocation AtLoc, 
-                                            StmtTy *Throw) {
+
+    virtual OwningStmtResult ActOnObjCAtThrowStmt(SourceLocation AtLoc,
+                                                  ExprArg Throw) {
       llvm::cout << __FUNCTION__ << "\n";
-      return 0;
+      return StmtEmpty();
     }
-  
-    virtual StmtResult ActOnObjCAtSynchronizedStmt(SourceLocation AtLoc, 
-                                                   ExprTy *SynchExpr, 
-                                                   StmtTy *SynchBody) {
+
+    virtual OwningStmtResult ActOnObjCAtSynchronizedStmt(SourceLocation AtLoc,
+                                                         ExprArg SynchExpr,
+                                                         StmtArg SynchBody) {
       llvm::cout << __FUNCTION__ << "\n";
-      return 0;
+      return StmtEmpty();
     }
 
     // C++ Statements

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

==============================================================================
--- cfe/trunk/include/clang/Parse/Action.h (original)
+++ cfe/trunk/include/clang/Parse/Action.h Sun Jan 18 11:43:11 2009
@@ -474,32 +474,33 @@
   }
 
   // Objective-c statements
-  virtual StmtResult ActOnObjCAtCatchStmt(SourceLocation AtLoc, 
-                                          SourceLocation RParen, StmtTy *Parm, 
-                                          StmtTy *Body, StmtTy *CatchList) {
-    return 0;
+  virtual OwningStmtResult ActOnObjCAtCatchStmt(SourceLocation AtLoc,
+                                                SourceLocation RParen,
+                                                StmtArg Parm, StmtArg Body,
+                                                StmtArg CatchList) {
+    return StmtEmpty();
   }
-  
-  virtual StmtResult ActOnObjCAtFinallyStmt(SourceLocation AtLoc, 
-                                            StmtTy *Body) {
-    return 0;
+
+  virtual OwningStmtResult ActOnObjCAtFinallyStmt(SourceLocation AtLoc,
+                                                  StmtArg Body) {
+    return StmtEmpty();
   }
-  
-  virtual StmtResult ActOnObjCAtTryStmt(SourceLocation AtLoc, 
-                                        StmtTy *Try, 
-                                        StmtTy *Catch, StmtTy *Finally) {
-    return 0;
+
+  virtual OwningStmtResult ActOnObjCAtTryStmt(SourceLocation AtLoc,
+                                              StmtArg Try, StmtArg Catch,
+                                              StmtArg Finally) {
+    return StmtEmpty();
   }
-  
-  virtual StmtResult ActOnObjCAtThrowStmt(SourceLocation AtLoc, 
-                                          StmtTy *Throw) {
-    return 0;
+
+  virtual OwningStmtResult ActOnObjCAtThrowStmt(SourceLocation AtLoc,
+                                                ExprArg Throw) {
+    return StmtEmpty();
   }
-  
-  virtual StmtResult ActOnObjCAtSynchronizedStmt(SourceLocation AtLoc, 
-                                        ExprTy *SynchExpr, 
-                                        StmtTy *SynchBody) {
-    return 0;
+
+  virtual OwningStmtResult ActOnObjCAtSynchronizedStmt(SourceLocation AtLoc,
+                                                       ExprArg SynchExpr,
+                                                       StmtArg SynchBody) {
+    return StmtEmpty();
   }
 
   // C++ Statements

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

==============================================================================
--- cfe/trunk/lib/Parse/ParseObjc.cpp (original)
+++ cfe/trunk/lib/Parse/ParseObjc.cpp Sun Jan 18 11:43:11 2009
@@ -1202,7 +1202,7 @@
     }
   }
   ConsumeToken(); // consume ';'
-  return Owned(Actions.ActOnObjCAtThrowStmt(atLoc, Res.release()));
+  return Actions.ActOnObjCAtThrowStmt(atLoc, move_convert(Res));
 }
 
 /// objc-synchronized-statement:
@@ -1239,8 +1239,8 @@
   BodyScope.Exit();
   if (SynchBody.isInvalid())
     SynchBody = Actions.ActOnNullStmt(Tok.getLocation());
-  return Owned(Actions.ActOnObjCAtSynchronizedStmt(atLoc, Res.release(),
-                                                   SynchBody.release()));
+  return Actions.ActOnObjCAtSynchronizedStmt(atLoc, move_convert(Res),
+                                             move_convert(SynchBody));
 }
 
 ///  objc-try-catch-statement:
@@ -1313,8 +1313,8 @@
         if (CatchBody.isInvalid())
           CatchBody = Actions.ActOnNullStmt(Tok.getLocation());
         CatchStmts = Actions.ActOnObjCAtCatchStmt(AtCatchFinallyLoc,
-          RParenLoc, FirstPart.release(), CatchBody.release(),
-          CatchStmts.release());
+          RParenLoc, move_convert(FirstPart), move_convert(CatchBody),
+          move_convert(CatchStmts));
       } else {
         Diag(AtCatchFinallyLoc, diag::err_expected_lparen_after)
           << "@catch clause";
@@ -1334,7 +1334,7 @@
       if (FinallyBody.isInvalid())
         FinallyBody = Actions.ActOnNullStmt(Tok.getLocation());
       FinallyStmt = Actions.ActOnObjCAtFinallyStmt(AtCatchFinallyLoc,
-                                                   FinallyBody.release());
+                                                   move_convert(FinallyBody));
       catch_or_finally_seen = true;
       break;
     }
@@ -1343,9 +1343,9 @@
     Diag(atLoc, diag::err_missing_catch_finally);
     return StmtError();
   }
-  return Owned(Actions.ActOnObjCAtTryStmt(atLoc, TryBody.release(),
-                                          CatchStmts.release(),
-                                          FinallyStmt.release()));
+  return Actions.ActOnObjCAtTryStmt(atLoc, move_convert(TryBody),
+                                    move_convert(CatchStmts),
+                                    move_convert(FinallyStmt));
 }
 
 ///   objc-method-def: objc-method-proto ';'[opt] '{' body '}'

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

==============================================================================
--- cfe/trunk/lib/Sema/Sema.h (original)
+++ cfe/trunk/lib/Sema/Sema.h Sun Jan 18 11:43:11 2009
@@ -912,23 +912,24 @@
                                         ExprArg AsmString,
                                         MultiExprArg Clobbers,
                                         SourceLocation RParenLoc);
-  
-  virtual StmtResult ActOnObjCAtCatchStmt(SourceLocation AtLoc, 
-                                          SourceLocation RParen, StmtTy *Parm, 
-                                          StmtTy *Body, StmtTy *CatchList);
-  
-  virtual StmtResult ActOnObjCAtFinallyStmt(SourceLocation AtLoc, 
-                                            StmtTy *Body);
-  
-  virtual StmtResult ActOnObjCAtTryStmt(SourceLocation AtLoc, 
-                                        StmtTy *Try, 
-                                        StmtTy *Catch, StmtTy *Finally);
-  
-  virtual StmtResult ActOnObjCAtThrowStmt(SourceLocation AtLoc, 
-                                          StmtTy *Throw);
-  virtual StmtResult ActOnObjCAtSynchronizedStmt(SourceLocation AtLoc, 
-                                                 ExprTy *SynchExpr, 
-                                                 StmtTy *SynchBody);
+
+  virtual OwningStmtResult ActOnObjCAtCatchStmt(SourceLocation AtLoc,
+                                                SourceLocation RParen,
+                                                StmtArg Parm, StmtArg Body,
+                                                StmtArg CatchList);
+
+  virtual OwningStmtResult ActOnObjCAtFinallyStmt(SourceLocation AtLoc,
+                                                  StmtArg Body);
+
+  virtual OwningStmtResult ActOnObjCAtTryStmt(SourceLocation AtLoc,
+                                              StmtArg Try,
+                                              StmtArg Catch, StmtArg Finally);
+
+  virtual OwningStmtResult ActOnObjCAtThrowStmt(SourceLocation AtLoc,
+                                                ExprArg Throw);
+  virtual OwningStmtResult ActOnObjCAtSynchronizedStmt(SourceLocation AtLoc,
+                                                       ExprArg SynchExpr,
+                                                       StmtArg SynchBody);
 
   virtual DeclTy *ActOnExceptionDeclarator(Scope *S, Declarator &D);
   virtual OwningStmtResult ActOnCXXCatchBlock(SourceLocation CatchLoc,

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

==============================================================================
--- cfe/trunk/lib/Sema/SemaStmt.cpp (original)
+++ cfe/trunk/lib/Sema/SemaStmt.cpp Sun Jan 18 11:43:11 2009
@@ -935,44 +935,42 @@
                            Clobbers, RParenLoc));
 }
 
-Action::StmtResult
-Sema::ActOnObjCAtCatchStmt(SourceLocation AtLoc, 
-                           SourceLocation RParen, StmtTy *Parm, 
-                           StmtTy *Body, StmtTy *CatchList) {
-  ObjCAtCatchStmt *CS = new ObjCAtCatchStmt(AtLoc, RParen, 
-    static_cast<Stmt*>(Parm), static_cast<Stmt*>(Body), 
-    static_cast<Stmt*>(CatchList));
-  return CatchList ? CatchList : CS;
-}
-
-Action::StmtResult
-Sema::ActOnObjCAtFinallyStmt(SourceLocation AtLoc, StmtTy *Body) {
-  ObjCAtFinallyStmt *FS = new ObjCAtFinallyStmt(AtLoc, 
-                                                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;
-}
-
-Action::StmtResult
-Sema::ActOnObjCAtThrowStmt(SourceLocation AtLoc, StmtTy *Throw) {
-  ObjCAtThrowStmt *TS = new ObjCAtThrowStmt(AtLoc, static_cast<Stmt*>(Throw));
-  return TS;
-}
-
-Action::StmtResult
-Sema::ActOnObjCAtSynchronizedStmt(SourceLocation AtLoc, ExprTy *SynchExpr, 
-                                  StmtTy *SynchBody) {
-  ObjCAtSynchronizedStmt *SS = new ObjCAtSynchronizedStmt(AtLoc, 
-    static_cast<Stmt*>(SynchExpr), static_cast<Stmt*>(SynchBody));
-  return SS;
+Action::OwningStmtResult
+Sema::ActOnObjCAtCatchStmt(SourceLocation AtLoc,
+                           SourceLocation RParen, StmtArg Parm,
+                           StmtArg Body, StmtArg catchList) {
+  Stmt *CatchList = static_cast<Stmt*>(catchList.release());
+  ObjCAtCatchStmt *CS = new ObjCAtCatchStmt(AtLoc, RParen,
+    static_cast<Stmt*>(Parm.release()), static_cast<Stmt*>(Body.release()),
+    CatchList);
+  return Owned(CatchList ? CatchList : CS);
+}
+
+Action::OwningStmtResult
+Sema::ActOnObjCAtFinallyStmt(SourceLocation AtLoc, StmtArg Body) {
+  return Owned(new ObjCAtFinallyStmt(AtLoc,
+                                     static_cast<Stmt*>(Body.release())));
+}
+
+Action::OwningStmtResult
+Sema::ActOnObjCAtTryStmt(SourceLocation AtLoc,
+                         StmtArg Try, StmtArg Catch, StmtArg Finally) {
+  return Owned(new ObjCAtTryStmt(AtLoc, static_cast<Stmt*>(Try.release()),
+                                        static_cast<Stmt*>(Catch.release()),
+                                        static_cast<Stmt*>(Finally.release())));
+}
+
+Action::OwningStmtResult
+Sema::ActOnObjCAtThrowStmt(SourceLocation AtLoc, ExprArg Throw) {
+  return Owned(new ObjCAtThrowStmt(AtLoc, static_cast<Expr*>(Throw.release())));
+}
+
+Action::OwningStmtResult
+Sema::ActOnObjCAtSynchronizedStmt(SourceLocation AtLoc, ExprArg SynchExpr,
+                                  StmtArg SynchBody) {
+  return Owned(new ObjCAtSynchronizedStmt(AtLoc,
+                     static_cast<Stmt*>(SynchExpr.release()),
+                     static_cast<Stmt*>(SynchBody.release())));
 }
 
 /// ActOnCXXCatchBlock - Takes an exception declaration and a handler block





More information about the cfe-commits mailing list