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/ParseDeclCXX.cpp b/lib/Parse/ParseDeclCXX.cpp
index c3b94bc..edcbfad 100644
--- a/lib/Parse/ParseDeclCXX.cpp
+++ b/lib/Parse/ParseDeclCXX.cpp
@@ -67,7 +67,7 @@
     SourceLocation LBrace = ConsumeBrace();
 
     // Enter a scope for the namespace.
-    EnterScope(Scope::DeclScope);
+    ParseScope NamespaceScope(this, Scope::DeclScope);
 
     DeclTy *NamespcDecl =
       Actions.ActOnStartNamespaceDef(CurScope, IdentLoc, Ident, LBrace);
@@ -76,7 +76,7 @@
       ParseExternalDeclaration();
     
     // Leave the namespace scope.
-    ExitScope();
+    NamespaceScope.Exit();
 
     SourceLocation RBrace = MatchRHSPunctuation(tok::r_brace, LBrace);
     Actions.ActOnFinishNamespaceDef(NamespcDecl, RBrace);
@@ -590,7 +590,7 @@
   }
 
   // Enter a scope for the class.
-  EnterScope(Scope::CXXClassScope|Scope::DeclScope);
+  ParseScope ClassScope(this, Scope::CXXClassScope|Scope::DeclScope);
 
   Actions.ActOnStartCXXClassDef(CurScope, TagDecl, LBraceLoc);
 
@@ -659,7 +659,7 @@
   }
 
   // Leave the class scope.
-  ExitScope();
+  ClassScope.Exit();
 
   Actions.ActOnFinishCXXClassDef(TagDecl);
 }