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/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp
index 5aaa0db..ec86b9f 100644
--- a/lib/Sema/SemaExpr.cpp
+++ b/lib/Sema/SemaExpr.cpp
@@ -505,14 +505,14 @@
   }
 
   // Verify that this is in a function context.
-  if (getCurFunctionDecl() == 0 && getCurMethodDecl() == 0)
+  if (getCurFunctionOrMethodDecl() == 0)
     return Diag(Loc, diag::err_predef_outside_function);
   
   // Pre-defined identifiers are of type char[x], where x is the length of the
   // string.
   unsigned Length;
-  if (getCurFunctionDecl())
-    Length = getCurFunctionDecl()->getIdentifier()->getLength();
+  if (FunctionDecl *FD = getCurFunctionDecl())
+    Length = FD->getIdentifier()->getLength();
   else
     Length = getCurMethodDecl()->getSynthesizedMethodSize();
   
@@ -1438,7 +1438,7 @@
                             DeclarationName()))
     return true;
 
-  bool isFileScope = !getCurFunctionDecl() && !getCurMethodDecl();
+  bool isFileScope = getCurFunctionOrMethodDecl() == 0;
   if (isFileScope) { // 6.5.2.5p3
     if (CheckForConstantInitializer(literalExpr, literalType))
       return true;