From: Shoaib Meenai Date: Fri, 30 Jun 2017 00:07:54 +0000 (+0000) Subject: [CodeGen] Propagate dllexport to thunks X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=6f6b2e231cef5e6714e42eebd485e6f798919a58;p=clang [CodeGen] Propagate dllexport to thunks Under Windows Itanium, we need to export virtual and non-virtual thunks if the functions being thunked are exported. These thunks would previously inherit their dllexport attribute from the declaration, but r298330 changed declarations to not have dllexport attributes. We therefore need to add the dllexport attribute to the definition ourselves now. Differential Revision: https://reviews.llvm.org/D34850 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@306770 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/CodeGen/CGVTables.cpp b/lib/CodeGen/CGVTables.cpp index 64b6d0d3fe..7c9f07d32d 100644 --- a/lib/CodeGen/CGVTables.cpp +++ b/lib/CodeGen/CGVTables.cpp @@ -64,6 +64,10 @@ static void setThunkProperties(CodeGenModule &CGM, const ThunkInfo &Thunk, const CXXMethodDecl *MD = cast(GD.getDecl()); setThunkVisibility(CGM, MD, Thunk, ThunkFn); + // Propagate dllexport storage. + if (MD->hasAttr()) + ThunkFn->setDLLStorageClass(llvm::GlobalValue::DLLExportStorageClass); + if (CGM.supportsCOMDAT() && ThunkFn->isWeakForLinker()) ThunkFn->setComdat(CGM.getModule().getOrInsertComdat(ThunkFn->getName())); } diff --git a/test/CodeGenCXX/windows-itanium-dllexport.cpp b/test/CodeGenCXX/windows-itanium-dllexport.cpp index ff780c7778..ffb8f610f5 100644 --- a/test/CodeGenCXX/windows-itanium-dllexport.cpp +++ b/test/CodeGenCXX/windows-itanium-dllexport.cpp @@ -53,3 +53,12 @@ USEMEMFUNC(outer::inner, f) // CHECK: declare dllimport {{.*}} @_ZN5outerIcE1fEv // CHECK: define {{.*}} @_ZN5outerIcE5inner1fEv + +struct base { + virtual ~base(); +}; +struct __declspec(dllexport) derived : public virtual base { + virtual ~derived() {} +}; + +// CHECK: define {{.*}} dllexport {{.*}} @_ZTv0_n12_N7derivedD0Ev