diff --git a/clang/lib/CodeGen/CGVTT.cpp b/clang/lib/CodeGen/CGVTT.cpp --- a/clang/lib/CodeGen/CGVTT.cpp +++ b/clang/lib/CodeGen/CGVTT.cpp @@ -96,9 +96,6 @@ if (CGM.supportsCOMDAT() && VTT->isWeakForLinker()) VTT->setComdat(CGM.getModule().getOrInsertComdat(VTT->getName())); - - // Set the right visibility. - CGM.setGVProperties(VTT, RD); } llvm::GlobalVariable *CodeGenVTables::GetAddrOfVTT(const CXXRecordDecl *RD) { @@ -122,6 +119,7 @@ llvm::GlobalVariable *GV = CGM.CreateOrReplaceCXXRuntimeVariable( Name, ArrayType, llvm::GlobalValue::ExternalLinkage, Align); GV->setUnnamedAddr(llvm::GlobalValue::UnnamedAddr::Global); + CGM.setGVProperties(GV, RD); return GV; } diff --git a/clang/test/CodeGenCXX/visibility.cpp b/clang/test/CodeGenCXX/visibility.cpp --- a/clang/test/CodeGenCXX/visibility.cpp +++ b/clang/test/CodeGenCXX/visibility.cpp @@ -118,6 +118,8 @@ // CHECK-HIDDEN: @_ZN6Test143varE = external global // CHECK: @_ZN6Test154TempINS_1AEE5Inner6bufferE = external global [0 x i8] // CHECK-HIDDEN: @_ZN6Test154TempINS_1AEE5Inner6bufferE = external global [0 x i8] +// CHECK: @_ZTVN6test701BE = external hidden unnamed_addr constant { [5 x ptr] }, align 8 +// CHECK: @_ZTTN6test701BE = external hidden unnamed_addr constant [2 x ptr], align 8 namespace test27 { template @@ -1317,3 +1319,16 @@ // CHECK-LABEL: define void @_ZN6test693foo1fEv // CHECK-HIDDEN-LABEL: define hidden void @_ZN6test693foo1fEv } + +namespace test70 { + // Make sure both the vtable and VTT declarations are marked "hidden" + class HIDDEN A { + virtual void a(); + }; + class HIDDEN B : virtual A { + void a() override; + ~B(); + }; + B::~B() {} + // Check lines at top of file. +}