]> granicus.if.org Git - clang/commitdiff
[CodeGen] Propagate dllexport to thunks
authorShoaib Meenai <smeenai@fb.com>
Fri, 30 Jun 2017 00:07:54 +0000 (00:07 +0000)
committerShoaib Meenai <smeenai@fb.com>
Fri, 30 Jun 2017 00:07:54 +0000 (00:07 +0000)
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

lib/CodeGen/CGVTables.cpp
test/CodeGenCXX/windows-itanium-dllexport.cpp

index 64b6d0d3fe9f5debf6f66c03a8ac0afc2157fb3a..7c9f07d32d8786320c822e5c0872354fb275dc3c 100644 (file)
@@ -64,6 +64,10 @@ static void setThunkProperties(CodeGenModule &CGM, const ThunkInfo &Thunk,
   const CXXMethodDecl *MD = cast<CXXMethodDecl>(GD.getDecl());
   setThunkVisibility(CGM, MD, Thunk, ThunkFn);
 
+  // Propagate dllexport storage.
+  if (MD->hasAttr<DLLExportAttr>())
+    ThunkFn->setDLLStorageClass(llvm::GlobalValue::DLLExportStorageClass);
+
   if (CGM.supportsCOMDAT() && ThunkFn->isWeakForLinker())
     ThunkFn->setComdat(CGM.getModule().getOrInsertComdat(ThunkFn->getName()));
 }
index ff780c777822d2ef464e0e685fea71026cb3d86c..ffb8f610f5c304f541af63a81d47bb6f8b8d0245 100644 (file)
@@ -53,3 +53,12 @@ USEMEMFUNC(outer<char>::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