Some utilities for using the smart pointers in Actions, especially Sema. Convert a few functions.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@60983 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp
index 2c5e46a..2890464 100644
--- a/lib/Sema/SemaDecl.cpp
+++ b/lib/Sema/SemaDecl.cpp
@@ -1884,9 +1884,9 @@
   return true;
 }
 
-void Sema::AddInitializerToDecl(DeclTy *dcl, ExprTy *init) {
+void Sema::AddInitializerToDecl(DeclTy *dcl, ExprArg init) {
   Decl *RealDecl = static_cast<Decl *>(dcl);
-  Expr *Init = static_cast<Expr *>(init);
+  Expr *Init = static_cast<Expr *>(init.release());
   assert(Init && "missing initializer");
   
   // If there is no declaration, there was an error parsing it.  Just ignore
@@ -2281,10 +2281,11 @@
   return FD;
 }
 
-Sema::DeclTy *Sema::ActOnFinishFunctionBody(DeclTy *D, StmtTy *Body) {
+Sema::DeclTy *Sema::ActOnFinishFunctionBody(DeclTy *D, StmtArg BodyArg) {
   Decl *dcl = static_cast<Decl *>(D);
+  Stmt *Body = static_cast<Stmt*>(BodyArg.release());
   if (FunctionDecl *FD = dyn_cast_or_null<FunctionDecl>(dcl)) {
-    FD->setBody((Stmt*)Body);
+    FD->setBody(Body);
     assert(FD == getCurFunctionDecl() && "Function parsing confused");
   } else if (ObjCMethodDecl *MD = dyn_cast_or_null<ObjCMethodDecl>(dcl)) {
     MD->setBody((Stmt*)Body);
@@ -2309,7 +2310,7 @@
       // formed.
       if (Body) {
         L->setSubStmt(new NullStmt(L->getIdentLoc()));
-        cast<CompoundStmt>((Stmt*)Body)->push_back(L);
+        cast<CompoundStmt>(Body)->push_back(L);
       } else {
         // The whole function wasn't parsed correctly, just delete this.
         delete L;
@@ -3358,9 +3359,9 @@
 }
 
 Sema::DeclTy *Sema::ActOnFileScopeAsmDecl(SourceLocation Loc,
-                                          ExprTy *expr) {
-  StringLiteral *AsmString = cast<StringLiteral>((Expr*)expr);
-  
+                                          ExprArg expr) {
+  StringLiteral *AsmString = cast<StringLiteral>((Expr*)expr.release());
+
   return FileScopeAsmDecl::Create(Context, Loc, AsmString);
 }