Inline LocalInstantiationScope::getInstantiationOf into its one
client, making room for future hacking.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@125770 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/include/clang/Sema/Template.h b/include/clang/Sema/Template.h
index 7b9b4a1..ce67031 100644
--- a/include/clang/Sema/Template.h
+++ b/include/clang/Sema/Template.h
@@ -253,6 +253,8 @@
     ~LocalInstantiationScope() {
       Exit();
     }
+    
+    const Sema &getSema() const { return SemaRef; }
 
     /// \brief Exit this local instantiation scope early.
     void Exit() {
@@ -266,8 +268,6 @@
       Exited = true;
     }
 
-    Decl *getInstantiationOf(const Decl *D);
-
     /// \brief Find the instantiation of the declaration D within the current
     /// instantiation scope.
     ///
diff --git a/lib/Sema/SemaTemplateInstantiate.cpp b/lib/Sema/SemaTemplateInstantiate.cpp
index 0ad9f7c..41e44ad 100644
--- a/lib/Sema/SemaTemplateInstantiate.cpp
+++ b/lib/Sema/SemaTemplateInstantiate.cpp
@@ -2166,17 +2166,6 @@
   return Instantiator.TransformTemplateArguments(Args, NumArgs, Result);
 }
 
-Decl *LocalInstantiationScope::getInstantiationOf(const Decl *D) {
-  llvm::PointerUnion<Decl *, DeclArgumentPack *> *Found= findInstantiationOf(D);
-  assert(Found);
-  
-  if (Found->is<Decl *>())
-    return Found->get<Decl *>();
-  
-  return (*Found->get<DeclArgumentPack *>())[
-                                        SemaRef.ArgumentPackSubstitutionIndex];
-}
-
 llvm::PointerUnion<Decl *, LocalInstantiationScope::DeclArgumentPack *> *
 LocalInstantiationScope::findInstantiationOf(const Decl *D) {
   for (LocalInstantiationScope *Current = this; Current; 
diff --git a/lib/Sema/SemaTemplateInstantiateDecl.cpp b/lib/Sema/SemaTemplateInstantiateDecl.cpp
index 1452423..9197b50 100644
--- a/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ b/lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -2860,7 +2860,16 @@
       (ParentDC->isFunctionOrMethod() && ParentDC->isDependentContext())) {
     // D is a local of some kind. Look into the map of local
     // declarations to their instantiations.
-    return cast<NamedDecl>(CurrentInstantiationScope->getInstantiationOf(D));
+    typedef LocalInstantiationScope::DeclArgumentPack DeclArgumentPack;
+    llvm::PointerUnion<Decl *, DeclArgumentPack *> *Found
+      = CurrentInstantiationScope->findInstantiationOf(D);
+    assert(Found);
+    
+    if (Decl *FD = Found->dyn_cast<Decl *>())
+      return cast<NamedDecl>(FD);
+    
+    unsigned PackIdx = ArgumentPackSubstitutionIndex;
+    return cast<NamedDecl>((*Found->get<DeclArgumentPack *>())[PackIdx]);
   }
 
   if (CXXRecordDecl *Record = dyn_cast<CXXRecordDecl>(D)) {