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/Sema.h b/lib/Sema/Sema.h
index f82651b..ef15064 100644
--- a/lib/Sema/Sema.h
+++ b/lib/Sema/Sema.h
@@ -329,16 +329,21 @@
   void PushDeclContext(DeclContext *DC);
   void PopDeclContext();
   
-  /// CurFunctionDecl - If inside of a function body, this returns a pointer to
-  /// the function decl for the function being parsed.
-  FunctionDecl *getCurFunctionDecl() {
-    return dyn_cast<FunctionDecl>(CurContext);
-  }
-
-  /// CurMethodDecl - If inside of a method body, this returns a pointer to
-  /// the method decl for the method being parsed.
+  /// getCurFunctionDecl - If inside of a function body, this returns a pointer
+  /// to the function decl for the function being parsed.  If we're currently
+  /// in a 'block', this returns the containing context.
+  FunctionDecl *getCurFunctionDecl();
+  
+  /// getCurMethodDecl - If inside of a method body, this returns a pointer to
+  /// the method decl for the method being parsed.  If we're currently
+  /// in a 'block', this returns the containing context.
   ObjCMethodDecl *getCurMethodDecl();
 
+  /// getCurFunctionOrMethodDecl - Return the Decl for the current ObjC method
+  /// or C function we're in, otherwise return null.  If we're currently
+  /// in a 'block', this returns the containing context.
+  NamedDecl *getCurFunctionOrMethodDecl();
+
   /// Add this decl to the scope shadowed decl chains.
   void PushOnScopeChains(NamedDecl *D, Scope *S);