From: Eli Friedman Date: Mon, 17 Jun 2013 21:51:45 +0000 (+0000) Subject: Compute the visibility of static local variables consistently. Fixes PR16208. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=93cc515d3b99dca18d287d200e19355a2e9c02b2;p=clang Compute the visibility of static local variables consistently. Fixes PR16208. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@184137 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/CodeGen/CGDecl.cpp b/lib/CodeGen/CGDecl.cpp index 614eaab3f3..429d2c8cca 100644 --- a/lib/CodeGen/CGDecl.cpp +++ b/lib/CodeGen/CGDecl.cpp @@ -218,8 +218,7 @@ CodeGenFunction::CreateStaticVarDecl(const VarDecl &D, llvm::GlobalVariable::NotThreadLocal, AddrSpace); GV->setAlignment(getContext().getDeclAlign(&D).getQuantity()); - if (Linkage != llvm::GlobalValue::InternalLinkage) - GV->setVisibility(CurFn->getVisibility()); + CGM.setGlobalVisibility(GV, &D); if (D.getTLSKind()) CGM.setTLSMode(GV, D); diff --git a/test/CodeGenCXX/visibility.cpp b/test/CodeGenCXX/visibility.cpp index 87add446ba..c5c47abd2b 100644 --- a/test/CodeGenCXX/visibility.cpp +++ b/test/CodeGenCXX/visibility.cpp @@ -139,6 +139,10 @@ namespace test27 { // CHECK: @_ZGVZN6Test193fooIiEEvvE1a = linkonce_odr global i64 // CHECK-HIDDEN: @_ZZN6Test193fooIiEEvvE1a = linkonce_odr hidden global // CHECK-HIDDEN: @_ZGVZN6Test193fooIiEEvvE1a = linkonce_odr hidden global i64 +// CHECK: @_ZZN6test681fC1EvE4test = linkonce_odr global +// CHECK: @_ZGVZN6test681fC1EvE4test = linkonce_odr global +// CHECK-HIDDEN: @_ZZN6test681fC1EvE4test = linkonce_odr hidden global +// CHECK-HIDDEN: @_ZGVZN6test681fC1EvE4test = linkonce_odr hidden global // CHECK-HIDDEN: @_ZTVN6Test161AIcEE = external unnamed_addr constant // CHECK-HIDDEN: @_ZTTN6Test161AIcEE = external unnamed_addr constant // CHECK: @_ZTVN5Test63fooE = linkonce_odr hidden unnamed_addr constant @@ -1277,3 +1281,17 @@ namespace test67 { // CHECK: define weak_odr void @_ZN6test673barINS_3fooEE3zedEv // CHECK-HIDDEN: define weak_odr void @_ZN6test673barINS_3fooEE3zedEv } + +namespace test68 { + class A { public: ~A(); }; + class f { + public: + f() { + static A test; + } + }; + void g() { + f a; + } + // Check lines at top of file. +}