Replace CurFunctionDecl and CurMethodDecl with methods getCurFunctionDecl() and getCurMethodDecl() that return the appropriate Decl through CurContext.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@52852 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/Sema.h b/lib/Sema/Sema.h
index 0dda082..73468dc 100644
--- a/lib/Sema/Sema.h
+++ b/lib/Sema/Sema.h
@@ -68,15 +68,8 @@
   Preprocessor &PP;
   ASTContext &Context;
   ASTConsumer &Consumer;
-  
-  /// CurFunctionDecl - If inside of a function body, this contains a pointer to
-  /// the function decl for the function being parsed.
-  FunctionDecl *CurFunctionDecl;
 
-  /// CurMethodDecl - If inside of a method body, this contains a pointer to
-  /// the method decl for the method being parsed.
-  ObjCMethodDecl *CurMethodDecl;
-
+  /// CurContext - This is the current declaration context of parsing.
   DeclContext *CurContext;
 
   /// LabelMap - This is a mapping from label identifiers to the LabelStmt for
@@ -267,6 +260,18 @@
   /// Set the current declaration context until it gets popped.
   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.
+  ObjCMethodDecl *getCurMethodDecl() {
+    return dyn_cast<ObjCMethodDecl>(CurContext);
+  }
 
   /// Add this decl to the scope shadowed decl chains.
   void PushOnScopeChains(NamedDecl *D, Scope *S);