]> granicus.if.org Git - clang/commitdiff
Inline LocalInstantiationScope::getInstantiationOf into its one
authorChris Lattner <sabre@nondot.org>
Thu, 17 Feb 2011 19:47:42 +0000 (19:47 +0000)
committerChris Lattner <sabre@nondot.org>
Thu, 17 Feb 2011 19:47:42 +0000 (19:47 +0000)
client, making room for future hacking.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@125770 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Sema/Template.h
lib/Sema/SemaTemplateInstantiate.cpp
lib/Sema/SemaTemplateInstantiateDecl.cpp

index 7b9b4a1c0e8a960733644e465b368073778035b6..ce670315e216b1fe64edb47f3eb7cab8ec159d2a 100644 (file)
@@ -253,6 +253,8 @@ namespace clang {
     ~LocalInstantiationScope() {
       Exit();
     }
+    
+    const Sema &getSema() const { return SemaRef; }
 
     /// \brief Exit this local instantiation scope early.
     void Exit() {
@@ -266,8 +268,6 @@ namespace clang {
       Exited = true;
     }
 
-    Decl *getInstantiationOf(const Decl *D);
-
     /// \brief Find the instantiation of the declaration D within the current
     /// instantiation scope.
     ///
index 0ad9f7c53fb3fd0874a989887b93e81c1a4c2b05..41e44ad6d10f9c6c0a0f801ab05e912bacc8bc42 100644 (file)
@@ -2166,17 +2166,6 @@ bool Sema::Subst(const TemplateArgumentLoc *Args, unsigned NumArgs,
   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; 
index 14524235d503fba228cefd7cb03270438fc107cc..9197b503302824ad53afd2066d1096dda467f9e0 100644 (file)
@@ -2860,7 +2860,16 @@ NamedDecl *Sema::FindInstantiatedDecl(SourceLocation Loc, NamedDecl *D,
       (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)) {