aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/SemaTemplateInstantiateDecl.cpp
diff options
context:
space:
mode:
authorAnders Carlsson <andersca@mac.com>2009-08-29 19:37:28 +0000
committerAnders Carlsson <andersca@mac.com>2009-08-29 19:37:28 +0000
commit0d8df780aef1acda5962347a32591efc629b6748 (patch)
tree19447c873904b8fce613430a89503a703342046f /lib/Sema/SemaTemplateInstantiateDecl.cpp
parent31976591dee494994f2546c72c23e1e35a9c1555 (diff)
Improve instantiation of UnresolvedUsingDecls.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@80434 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaTemplateInstantiateDecl.cpp')
-rw-r--r--lib/Sema/SemaTemplateInstantiateDecl.cpp28
1 files changed, 23 insertions, 5 deletions
diff --git a/lib/Sema/SemaTemplateInstantiateDecl.cpp b/lib/Sema/SemaTemplateInstantiateDecl.cpp
index 6c1f0115b6..5978dae311 100644
--- a/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ b/lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -757,9 +757,14 @@ TemplateDeclInstantiator::VisitUnresolvedUsingDecl(UnresolvedUsingDecl *D) {
SS.setRange(D->getTargetNestedNameRange());
SS.setScopeRep(NNS);
- return SemaRef.BuildUsingDeclaration(D->getLocation(), SS,
- D->getTargetNameLocation(),
- D->getTargetName(), 0, D->isTypeName());
+ NamedDecl *UD =
+ SemaRef.BuildUsingDeclaration(D->getLocation(), SS,
+ D->getTargetNameLocation(),
+ D->getTargetName(), 0, D->isTypeName());
+ if (UD)
+ SemaRef.Context.setInstantiatedFromUnresolvedUsingDecl(cast<UsingDecl>(UD),
+ D);
+ return UD;
}
Decl *Sema::SubstDecl(Decl *D, DeclContext *Owner,
@@ -1220,6 +1225,12 @@ static bool isInstantiationOf(EnumDecl *Pattern,
return false;
}
+static bool isInstantiationOf(UnresolvedUsingDecl *Pattern,
+ UsingDecl *Instance,
+ ASTContext &C) {
+ return C.getInstantiatedFromUnresolvedUsingDecl(Instance) == Pattern;
+}
+
static bool isInstantiationOfStaticDataMember(VarDecl *Pattern,
VarDecl *Instance) {
assert(Instance->isStaticDataMember());
@@ -1236,9 +1247,16 @@ static bool isInstantiationOfStaticDataMember(VarDecl *Pattern,
}
static bool isInstantiationOf(ASTContext &Ctx, NamedDecl *D, Decl *Other) {
- if (D->getKind() != Other->getKind())
- return false;
+ if (D->getKind() != Other->getKind()) {
+ if (UnresolvedUsingDecl *UUD = dyn_cast<UnresolvedUsingDecl>(D)) {
+ if (UsingDecl *UD = dyn_cast<UsingDecl>(Other)) {
+ return isInstantiationOf(UUD, UD, Ctx);
+ }
+ }
+ return false;
+ }
+
if (CXXRecordDecl *Record = dyn_cast<CXXRecordDecl>(Other))
return isInstantiationOf(cast<CXXRecordDecl>(D), Record);