Move fix in r54013 from the parser to sema.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@54032 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp
index 25d4ad5..4d726cf 100644
--- a/lib/Sema/SemaDecl.cpp
+++ b/lib/Sema/SemaDecl.cpp
@@ -1576,12 +1576,13 @@
 
 Sema::DeclTy *Sema::ActOnFinishFunctionBody(DeclTy *D, StmtTy *Body) {
   Decl *dcl = static_cast<Decl *>(D);
-  if (FunctionDecl *FD = dyn_cast<FunctionDecl>(dcl)) {
+  if (FunctionDecl *FD = dyn_cast_or_null<FunctionDecl>(dcl)) {
     FD->setBody((Stmt*)Body);
     assert(FD == getCurFunctionDecl() && "Function parsing confused");
-  } else if (ObjCMethodDecl *MD = dyn_cast<ObjCMethodDecl>(dcl)) {
+  } else if (ObjCMethodDecl *MD = dyn_cast_or_null<ObjCMethodDecl>(dcl)) {
     MD->setBody((Stmt*)Body);
-  }  
+  } else
+    return 0;
   PopDeclContext();
   // Verify and clean out per-function state.