[cfe-commits] r156897 - in /cfe/trunk: lib/AST/Decl.cpp test/CodeGenCXX/visibility.cpp
Rafael Espindola
rafael.espindola at gmail.com
Tue May 15 19:10:38 PDT 2012
Author: rafael
Date: Tue May 15 21:10:38 2012
New Revision: 156897
URL: http://llvm.org/viewvc/llvm-project?rev=156897&view=rev
Log:
Fix the visibility of instantiations of static data members.
Fixes pr12835.
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=156897&r1=156896&r2=156897&view=diff
==============================================================================
--- cfe/trunk/lib/AST/Decl.cpp (original)
+++ cfe/trunk/lib/AST/Decl.cpp Tue May 15 21:10:38 2012
@@ -633,9 +633,19 @@
llvm::Optional<Visibility> NamedDecl::getExplicitVisibility() const {
// Use the most recent declaration of a variable.
- if (const VarDecl *var = dyn_cast<VarDecl>(this))
- return getVisibilityOf(var->getMostRecentDecl());
+ if (const VarDecl *Var = dyn_cast<VarDecl>(this)) {
+ if (llvm::Optional<Visibility> V =
+ getVisibilityOf(Var->getMostRecentDecl()))
+ return V;
+
+ if (Var->isStaticDataMember()) {
+ VarDecl *InstantiatedFrom = Var->getInstantiatedFromStaticDataMember();
+ if (InstantiatedFrom)
+ return getVisibilityOf(InstantiatedFrom);
+ }
+ return llvm::Optional<Visibility>();
+ }
// Use the most recent declaration of a function, and also handle
// function template specializations.
if (const FunctionDecl *fn = dyn_cast<FunctionDecl>(this)) {
Modified: cfe/trunk/test/CodeGenCXX/visibility.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/visibility.cpp?rev=156897&r1=156896&r2=156897&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/visibility.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/visibility.cpp Tue May 15 21:10:38 2012
@@ -54,6 +54,18 @@
// CHECK-HIDDEN: @_ZN6test299data_rectE = global
}
+namespace test40 {
+ template<typename T>
+ struct foo {
+ DEFAULT static int bar;
+ };
+ template<typename T>
+ int foo<T>::bar;
+ template struct foo<int>;
+ // CHECK: _ZN6test403fooIiE3barE = weak_odr global
+ // CHECK-HIDDEN: _ZN6test403fooIiE3barE = weak_odr global
+}
+
// CHECK: @_ZN5Test425VariableInHiddenNamespaceE = hidden global i32 10
// CHECK: @_ZN5Test71aE = hidden global
// CHECK: @_ZN5Test71bE = global
More information about the cfe-commits
mailing list