Use a scoped object to manage entry/exit from a parser scope rather than explicitly calling EnterScope/ExitScope

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@60830 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Parse/Parser.cpp b/lib/Parse/Parser.cpp
index d040efd..3d72b60 100644
--- a/lib/Parse/Parser.cpp
+++ b/lib/Parse/Parser.cpp
@@ -287,7 +287,7 @@
 ///         external-declaration
 ///         translation-unit external-declaration
 void Parser::ParseTranslationUnit() {
-  Initialize();  // pushes a scope.
+  Initialize();
 
   DeclTy *Res;
   while (!ParseTopLevelDecl(Res))
@@ -526,7 +526,7 @@
   }
 
   // Enter a scope for the function body.
-  EnterScope(Scope::FnScope|Scope::DeclScope);
+  ParseScope BodyScope(this, Scope::FnScope|Scope::DeclScope);
 
   // Tell the actions module that we have entered a function definition with the
   // specified Declarator for the function.
@@ -549,7 +549,7 @@
 
   // Enter function-declaration scope, limiting any declarators to the
   // function prototype scope, including parameter declarators.
-  EnterScope(Scope::FnScope|Scope::DeclScope);
+  ParseScope PrototypeScope(this, Scope::FnScope|Scope::DeclScope);
 
   // Read all the argument declarations.
   while (isDeclarationSpecifier()) {
@@ -653,9 +653,6 @@
     }
   }
 
-  // Leave prototype scope.
-  ExitScope();
-
   // The actions module must verify that all arguments were declared.
 }