diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2015-06-17 20:39:41 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2015-06-17 20:39:41 +0000 |
commit | 63e09bf70b65610e54837b57e6fca0c5492db8df (patch) | |
tree | d08e6e9ab31683f906ea93d8cd5037885a9a53f2 /clang/lib/Sema/SemaLookup.cpp | |
parent | bb71f7d25106b366a31ab74d8c03eeda99d6a64f (diff) | |
download | bcm5719-llvm-63e09bf70b65610e54837b57e6fca0c5492db8df.tar.gz bcm5719-llvm-63e09bf70b65610e54837b57e6fca0c5492db8df.zip |
[modules] If we merge a template, also track that its parameters are merged so
that we know when its default arguments should be visible.
llvm-svn: 239936
Diffstat (limited to 'clang/lib/Sema/SemaLookup.cpp')
-rw-r--r-- | clang/lib/Sema/SemaLookup.cpp | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/clang/lib/Sema/SemaLookup.cpp b/clang/lib/Sema/SemaLookup.cpp index 75d4709e19b..3fd1f21ba3f 100644 --- a/clang/lib/Sema/SemaLookup.cpp +++ b/clang/lib/Sema/SemaLookup.cpp @@ -1228,13 +1228,17 @@ Module *Sema::getOwningModule(Decl *Entity) { } void Sema::makeMergedDefinitionVisible(NamedDecl *ND, SourceLocation Loc) { - // FIXME: If ND is a template declaration, make the template parameters - // visible too. They're not (necessarily) within its DeclContext. if (auto *M = PP.getModuleContainingLocation(Loc)) Context.mergeDefinitionIntoModule(ND, M); else // We're not building a module; just make the definition visible. ND->setHidden(false); + + // If ND is a template declaration, make the template parameters + // visible too. They're not (necessarily) within a mergeable DeclContext. + if (auto *TD = dyn_cast<TemplateDecl>(ND)) + for (auto *Param : *TD->getTemplateParameters()) + makeMergedDefinitionVisible(Param, Loc); } /// \brief Find the module in which the given declaration was defined. @@ -1296,8 +1300,12 @@ hasVisibleDefaultArgument(Sema &S, const ParmDecl *D, if (!DefaultArg.isInherited() && S.isVisible(D)) return true; - if (!DefaultArg.isInherited() && Modules) - Modules->push_back(S.getOwningModule(const_cast<ParmDecl*>(D))); + if (!DefaultArg.isInherited() && Modules) { + auto *NonConstD = const_cast<ParmDecl*>(D); + Modules->push_back(S.getOwningModule(NonConstD)); + const auto &Merged = S.Context.getModulesWithMergedDefinition(NonConstD); + Modules->insert(Modules->end(), Merged.begin(), Merged.end()); + } // If there was a previous default argument, maybe its parameter is visible. D = DefaultArg.getInheritedFrom(); |