r207498 - AST: Fix visibility calculation for VarTemplateSpecializationDecl
David Majnemer
david.majnemer at gmail.com
Tue Apr 29 00:32:41 PDT 2014
Author: majnemer
Date: Tue Apr 29 02:32:26 2014
New Revision: 207498
URL: http://llvm.org/viewvc/llvm-project?rev=207498&view=rev
Log:
AST: Fix visibility calculation for VarTemplateSpecializationDecl
It is possible that a variable template specialization might not have a
VisibilityAttr attached to it while the template that it specializes
does, in fact, have one.
We should consider the template in such cases.
This fixes PR19597.
Modified:
cfe/trunk/lib/AST/Decl.cpp
cfe/trunk/test/CodeGenCXX/const-init-cxx1y.cpp
Modified: cfe/trunk/lib/AST/Decl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Decl.cpp?rev=207498&r1=207497&r2=207498&view=diff
==============================================================================
--- cfe/trunk/lib/AST/Decl.cpp (original)
+++ cfe/trunk/lib/AST/Decl.cpp Tue Apr 29 02:32:26 2014
@@ -982,6 +982,10 @@ getExplicitVisibilityAux(const NamedDecl
return getVisibilityOf(InstantiatedFrom, kind);
}
+ if (const auto *VTSD = dyn_cast<VarTemplateSpecializationDecl>(Var))
+ return getVisibilityOf(VTSD->getSpecializedTemplate()->getTemplatedDecl(),
+ kind);
+
return None;
}
// Also handle function template specializations.
Modified: cfe/trunk/test/CodeGenCXX/const-init-cxx1y.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/const-init-cxx1y.cpp?rev=207498&r1=207497&r2=207498&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/const-init-cxx1y.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/const-init-cxx1y.cpp Tue Apr 29 02:32:26 2014
@@ -46,6 +46,14 @@ namespace VariableTemplateWithConstRef {
const int &use = i<void>;
}
+// CHECK: @_ZGRN34HiddenVariableTemplateWithConstRef1iIvEE = linkonce_odr hidden constant i32 5, align 4
+// CHECK: @_ZN34HiddenVariableTemplateWithConstRef3useE = constant i32* @_ZGRN34HiddenVariableTemplateWithConstRef1iIvEE
+namespace HiddenVariableTemplateWithConstRef {
+ template <typename T>
+ __attribute__((visibility("hidden"))) const int &i = 5;
+ const int &use = i<void>;
+}
+
// CHECK: @_ZGRN24VariableTemplateWithPack1sIJLi1ELi2ELi3ELi4EEEE = linkonce_odr constant i32 1
// CHECK: @_ZGRN24VariableTemplateWithPack1sIJLi1ELi2ELi3ELi4EEEE2 = linkonce_odr global {{.*}} { i32* @_ZGRN24VariableTemplateWithPack1sIJLi1ELi2ELi3ELi4EEEE }
// CHECK: @_ZGRN24VariableTemplateWithPack1sIJLi1ELi2ELi3ELi4EEEE3 = linkonce_odr constant i32 2
More information about the cfe-commits
mailing list