change getCurFunctionDecl to skip through Block contexts to find
the containing block.  Introduce a new getCurFunctionOrMethodDecl
method to check to see if we're in a function or objc method.
Minor cleanups to other related places.  This fixes rdar://6405429.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@60564 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaStmt.cpp b/lib/Sema/SemaStmt.cpp
index a469713..0159f5f 100644
--- a/lib/Sema/SemaStmt.cpp
+++ b/lib/Sema/SemaStmt.cpp
@@ -750,9 +750,12 @@
   Expr *RetValExp = static_cast<Expr *>(rex);
   if (CurBlock)
     return ActOnBlockReturnStmt(ReturnLoc, RetValExp);
-  QualType FnRetType =
-        getCurFunctionDecl() ? getCurFunctionDecl()->getResultType() : 
-                               getCurMethodDecl()->getResultType();
+  
+  QualType FnRetType;
+  if (FunctionDecl *FD = getCurFunctionDecl())
+    FnRetType = FD->getResultType();
+  else
+    FnRetType = getCurMethodDecl()->getResultType();
 
   if (FnRetType->isVoidType()) {
     if (RetValExp) {// C99 6.8.6.4p1 (ext_ since GCC warns)