Simplify, and improve the performance of, template instantiation for
declaration references. The key realization is that dependent Decls,
which actually require instantiation, can only refer to the current
instantiation or members thereof. And, since the current context
during instantiation contains all of those members of the current
instantiation, we can simply find the real instantiate that matches up
with the "current instantiation" template.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72486 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaTemplateInstantiate.cpp b/lib/Sema/SemaTemplateInstantiate.cpp
index 1cc9992..1546e39 100644
--- a/lib/Sema/SemaTemplateInstantiate.cpp
+++ b/lib/Sema/SemaTemplateInstantiate.cpp
@@ -407,8 +407,8 @@
TemplateTypeInstantiator::InstantiateTypedefType(const TypedefType *T,
unsigned Quals) const {
TypedefDecl *Typedef
- = cast_or_null<TypedefDecl>(SemaRef.InstantiateDeclRef(T->getDecl(),
- TemplateArgs));
+ = cast_or_null<TypedefDecl>(
+ SemaRef.InstantiateCurrentDeclRef(T->getDecl()));
if (!Typedef)
return QualType();
@@ -440,8 +440,7 @@
TemplateTypeInstantiator::InstantiateRecordType(const RecordType *T,
unsigned Quals) const {
RecordDecl *Record
- = cast_or_null<RecordDecl>(SemaRef.InstantiateDeclRef(T->getDecl(),
- TemplateArgs));
+ = cast_or_null<RecordDecl>(SemaRef.InstantiateCurrentDeclRef(T->getDecl()));
if (!Record)
return QualType();
@@ -452,8 +451,7 @@
TemplateTypeInstantiator::InstantiateEnumType(const EnumType *T,
unsigned Quals) const {
EnumDecl *Enum
- = cast_or_null<EnumDecl>(SemaRef.InstantiateDeclRef(T->getDecl(),
- TemplateArgs));
+ = cast_or_null<EnumDecl>(SemaRef.InstantiateCurrentDeclRef(T->getDecl()));
if (!Enum)
return QualType();