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/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)) {