diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2012-05-15 14:09:55 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2012-05-15 14:09:55 +0000 |
commit | 7f90b7d4c29d560b57f6026f886adbf4d7ab4382 (patch) | |
tree | 8deceb9b6521e1a8548a310c67e57b17ac102e9d /clang/lib/AST/Decl.cpp | |
parent | ab5edc3e89901f822fd27c98613afad493cfd041 (diff) | |
download | bcm5719-llvm-7f90b7d4c29d560b57f6026f886adbf4d7ab4382.tar.gz bcm5719-llvm-7f90b7d4c29d560b57f6026f886adbf4d7ab4382.zip |
Fix our handling of visibility in explicit template instantiations.
* Don't copy the visibility attribute during instantiations. We have to be able
to distinguish
struct HIDDEN foo {};
template<class T>
DEFAULT void bar() {}
template DEFAULT void bar<foo>();
from
struct HIDDEN foo {};
template<class T>
DEFAULT void bar() {}
template void bar<foo>();
* If an instantiation has an attribute, it takes precedence over an attribute
in the template.
* With instantiation attributes handled with the above logic, we can now
select the minimum visibility when looking at template arguments.
llvm-svn: 156821
Diffstat (limited to 'clang/lib/AST/Decl.cpp')
-rw-r--r-- | clang/lib/AST/Decl.cpp | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp index 15fa7902031..21405d223d1 100644 --- a/clang/lib/AST/Decl.cpp +++ b/clang/lib/AST/Decl.cpp @@ -158,14 +158,12 @@ getLVForTemplateArgumentList(const TemplateArgumentList &TArgs, return getLVForTemplateArgumentList(TArgs.data(), TArgs.size(), OnlyTemplate); } -static bool shouldConsiderTemplateLV(const FunctionDecl *fn, - const FunctionTemplateSpecializationInfo *spec) { - return !(spec->isExplicitSpecialization() && - fn->hasAttr<VisibilityAttr>()); +static bool shouldConsiderTemplateLV(const FunctionDecl *fn) { + return !fn->hasAttr<VisibilityAttr>(); } static bool shouldConsiderTemplateLV(const ClassTemplateSpecializationDecl *d) { - return !(d->isExplicitSpecialization() && d->hasAttr<VisibilityAttr>()); + return !d->hasAttr<VisibilityAttr>(); } static LinkageInfo getLVForNamespaceScopeDecl(const NamedDecl *D, @@ -376,7 +374,7 @@ static LinkageInfo getLVForNamespaceScopeDecl(const NamedDecl *D, // this is an explicit specialization with a visibility attribute. if (FunctionTemplateSpecializationInfo *specInfo = Function->getTemplateSpecializationInfo()) { - if (shouldConsiderTemplateLV(Function, specInfo)) { + if (shouldConsiderTemplateLV(Function)) { LV.merge(getLVForDecl(specInfo->getTemplate(), true)); const TemplateArgumentList &templateArgs = *specInfo->TemplateArguments; @@ -407,8 +405,8 @@ static LinkageInfo getLVForNamespaceScopeDecl(const NamedDecl *D, // The arguments at which the template was instantiated. const TemplateArgumentList &TemplateArgs = spec->getTemplateArgs(); - LV.merge(getLVForTemplateArgumentList(TemplateArgs, - OnlyTemplate)); + LV.mergeWithMin(getLVForTemplateArgumentList(TemplateArgs, + OnlyTemplate)); } } @@ -527,7 +525,7 @@ static LinkageInfo getLVForClassMember(const NamedDecl *D, bool OnlyTemplate) { // the template parameters and arguments. if (FunctionTemplateSpecializationInfo *spec = MD->getTemplateSpecializationInfo()) { - if (shouldConsiderTemplateLV(MD, spec)) { + if (shouldConsiderTemplateLV(MD)) { LV.mergeWithMin(getLVForTemplateArgumentList(*spec->TemplateArguments, OnlyTemplate)); if (!OnlyTemplate) |