diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2012-05-25 16:41:35 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2012-05-25 16:41:35 +0000 |
commit | 9db614f339f7596e2c0e0e04d6c714cd264ce883 (patch) | |
tree | fd7704ed27cbe6cbcae689e4f8dc044a7b2c7d92 /lib/AST/Decl.cpp | |
parent | e41458c37923c77fdae39676b3b4bce9f6c80def (diff) |
Don't ignore linkage when ignoring visibility in the instantiation of a
function template.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@157480 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AST/Decl.cpp')
-rw-r--r-- | lib/AST/Decl.cpp | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/lib/AST/Decl.cpp b/lib/AST/Decl.cpp index e8d7093a3f..405c2b328f 100644 --- a/lib/AST/Decl.cpp +++ b/lib/AST/Decl.cpp @@ -158,7 +158,7 @@ getLVForTemplateArgumentList(const TemplateArgumentList &TArgs, return getLVForTemplateArgumentList(TArgs.data(), TArgs.size(), OnlyTemplate); } -static bool shouldConsiderTemplateLV(const FunctionDecl *fn, +static bool shouldConsiderTemplateVis(const FunctionDecl *fn, const FunctionTemplateSpecializationInfo *spec) { return !fn->hasAttr<VisibilityAttr>() || spec->isExplicitSpecialization(); } @@ -376,12 +376,16 @@ static LinkageInfo getLVForNamespaceScopeDecl(const NamedDecl *D, // this is an explicit specialization with a visibility attribute. if (FunctionTemplateSpecializationInfo *specInfo = Function->getTemplateSpecializationInfo()) { - if (shouldConsiderTemplateLV(Function, specInfo)) { - LV.merge(getLVForDecl(specInfo->getTemplate(), - true)); - const TemplateArgumentList &templateArgs = *specInfo->TemplateArguments; - LV.mergeWithMin(getLVForTemplateArgumentList(templateArgs, - OnlyTemplate)); + LinkageInfo TempLV = getLVForDecl(specInfo->getTemplate(), true); + const TemplateArgumentList &templateArgs = *specInfo->TemplateArguments; + LinkageInfo ArgsLV = getLVForTemplateArgumentList(templateArgs, + OnlyTemplate); + if (shouldConsiderTemplateVis(Function, specInfo)) { + LV.merge(TempLV); + LV.mergeWithMin(ArgsLV); + } else { + LV.mergeLinkage(TempLV); + LV.mergeLinkage(ArgsLV); } } @@ -531,7 +535,7 @@ static LinkageInfo getLVForClassMember(const NamedDecl *D, bool OnlyTemplate) { // the template parameters and arguments. if (FunctionTemplateSpecializationInfo *spec = MD->getTemplateSpecializationInfo()) { - if (shouldConsiderTemplateLV(MD, spec)) { + if (shouldConsiderTemplateVis(MD, spec)) { LV.mergeWithMin(getLVForTemplateArgumentList(*spec->TemplateArguments, OnlyTemplate)); if (!OnlyTemplate) |