summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaLookup.cpp
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2017-04-19 01:36:43 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2017-04-19 01:36:43 +0000
commit5aacc4021bf3d689cbfd8921666b098441746054 (patch)
treeaca77e5ca9d4e933b32a0a9c64478386b701ddb1 /clang/lib/Sema/SemaLookup.cpp
parent6ded58e27962754957834752173aa6ac60f5e1e7 (diff)
downloadbcm5719-llvm-5aacc4021bf3d689cbfd8921666b098441746054.tar.gz
bcm5719-llvm-5aacc4021bf3d689cbfd8921666b098441746054.zip
[modules] Properly look up the owning module for an instantiation of a merged template.
When looking for the template instantiation pattern of a templated entity, consistently select the definition of the pattern if there is one. This means we'll pick the same owning module when we start instantiating a template that we'll later pick when determining which modules are visible during that instantiation. llvm-svn: 300650
Diffstat (limited to 'clang/lib/Sema/SemaLookup.cpp')
-rw-r--r--clang/lib/Sema/SemaLookup.cpp22
1 files changed, 5 insertions, 17 deletions
diff --git a/clang/lib/Sema/SemaLookup.cpp b/clang/lib/Sema/SemaLookup.cpp
index e4d420f3683..0ac3eebcf29 100644
--- a/clang/lib/Sema/SemaLookup.cpp
+++ b/clang/lib/Sema/SemaLookup.cpp
@@ -1326,12 +1326,6 @@ bool Sema::CppLookupName(LookupResult &R, Scope *S) {
return !R.empty();
}
-/// \brief Find the declaration that a class temploid member specialization was
-/// instantiated from, or the member itself if it is an explicit specialization.
-static Decl *getInstantiatedFrom(Decl *D, MemberSpecializationInfo *MSInfo) {
- return MSInfo->isExplicitSpecialization() ? D : MSInfo->getInstantiatedFrom();
-}
-
Module *Sema::getOwningModule(Decl *Entity) {
// If it's imported, grab its owning module.
Module *M = Entity->getImportedOwningModule();
@@ -1413,20 +1407,14 @@ static Module *getDefiningModule(Sema &S, Decl *Entity) {
if (CXXRecordDecl *Pattern = RD->getTemplateInstantiationPattern())
Entity = Pattern;
} else if (EnumDecl *ED = dyn_cast<EnumDecl>(Entity)) {
- if (MemberSpecializationInfo *MSInfo = ED->getMemberSpecializationInfo())
- Entity = getInstantiatedFrom(ED, MSInfo);
+ if (auto *Pattern = ED->getTemplateInstantiationPattern())
+ Entity = Pattern;
} else if (VarDecl *VD = dyn_cast<VarDecl>(Entity)) {
- // FIXME: Map from variable template specializations back to the template.
- if (MemberSpecializationInfo *MSInfo = VD->getMemberSpecializationInfo())
- Entity = getInstantiatedFrom(VD, MSInfo);
+ if (VarDecl *Pattern = VD->getTemplateInstantiationPattern())
+ Entity = Pattern;
}
- // Walk up to the containing context. That might also have been instantiated
- // from a template.
- DeclContext *Context = Entity->getDeclContext();
- if (Context->isFileContext())
- return S.getOwningModule(Entity);
- return getDefiningModule(S, cast<Decl>(Context));
+ return S.getOwningModule(Entity);
}
llvm::DenseSet<Module*> &Sema::getLookupModules() {
OpenPOWER on IntegriCloud