[cfe-commits] r157480 - in /cfe/trunk: lib/AST/Decl.cpp test/CodeGenCXX/visibility.cpp
Rafael Espindola
rafael.espindola at gmail.com
Fri May 25 09:41:36 PDT 2012
Author: rafael
Date: Fri May 25 11:41:35 2012
New Revision: 157480
URL: http://llvm.org/viewvc/llvm-project?rev=157480&view=rev
Log:
Don't ignore linkage when ignoring visibility in the instantiation of a
function template.
Modified:
cfe/trunk/lib/AST/Decl.cpp
cfe/trunk/test/CodeGenCXX/visibility.cpp
Modified: cfe/trunk/lib/AST/Decl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Decl.cpp?rev=157480&r1=157479&r2=157480&view=diff
==============================================================================
--- cfe/trunk/lib/AST/Decl.cpp (original)
+++ cfe/trunk/lib/AST/Decl.cpp Fri May 25 11:41:35 2012
@@ -158,7 +158,7 @@
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 @@
// 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 @@
// 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)
Modified: cfe/trunk/test/CodeGenCXX/visibility.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/visibility.cpp?rev=157480&r1=157479&r2=157480&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/visibility.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/visibility.cpp Fri May 25 11:41:35 2012
@@ -849,3 +849,18 @@
// CHECK: define internal void @_ZN6test453fooIiE3barINS_12_GLOBAL__N_13zedEEC1Ev
// CHECK-HIDDEN: define internal void @_ZN6test453fooIiE3barINS_12_GLOBAL__N_13zedEEC1Ev
}
+
+namespace test46 {
+ template <typename T>
+ void foo() {
+ }
+ namespace {
+ struct bar;
+ }
+ template DEFAULT void foo<bar>();
+ void zed() {
+ foo<bar>();
+ }
+ // CHECK: define internal void @_ZN6test463fooINS_12_GLOBAL__N_13barEEEvv
+ // CHECK-HIDDEN: define internal void @_ZN6test463fooINS_12_GLOBAL__N_13barEEEvv
+}
More information about the cfe-commits
mailing list