Factor out some common code into Sema::EnterDeclaratorContext/ExitDeclaratorContext.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@73655 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaDeclCXX.cpp b/lib/Sema/SemaDeclCXX.cpp
index bb1f50f..a37929c 100644
--- a/lib/Sema/SemaDeclCXX.cpp
+++ b/lib/Sema/SemaDeclCXX.cpp
@@ -2852,12 +2852,7 @@
   // was used in a member function of X.
   
   // Change current context into the context of the initializing declaration.
-  
-  assert(PreDeclaratorDC == 0 && "Previous declarator context not popped?");
-  PreDeclaratorDC = static_cast<DeclContext*>(S->getEntity());
-  CurContext = D->getDeclContext();
-  assert(CurContext && "No context?");
-  S->setEntity(CurContext);
+  EnterDeclaratorContext(S, D->getDeclContext());
 }
 
 /// ActOnCXXExitDeclInitializer - Invoked after we are finished parsing an
@@ -2874,12 +2869,5 @@
     return;
 
   assert(S->getEntity() == D->getDeclContext() && "Context imbalance!");
-  S->setEntity(PreDeclaratorDC);
-  PreDeclaratorDC = 0;
-
-  // Reset CurContext to the nearest enclosing context.
-  while (!S->getEntity() && S->getParent())
-    S = S->getParent();
-  CurContext = static_cast<DeclContext*>(S->getEntity());
-  assert(CurContext && "No context?");
+  ExitDeclaratorContext(S);
 }