[PATCH] Start adding support for dllimport/dllexport on classes (PR11170)

Reid Kleckner rnk at google.com
Thu May 29 17:35:05 PDT 2014


lgtm

There's still work to be done, but Richard thinks this is "basically fine" and IMO it's time to land and iterate.

================
Comment at: lib/CodeGen/CGVTables.cpp:663
@@ +662,3 @@
+  } else if (RD->hasAttr<DLLImportAttr>()) {
+    // Imported functions are available externally.
+    DiscardableODRLinkage = llvm::GlobalVariable::AvailableExternallyLinkage;
----------------
"Imported vtables"

================
Comment at: lib/CodeGen/MicrosoftCXXABI.cpp:205
@@ -204,2 +204,3 @@
   void setThunkLinkage(llvm::Function *Thunk, bool ForVTable) override {
     Thunk->setLinkage(llvm::GlobalValue::WeakAnyLinkage);
+
----------------
I wonder why thunks are WeakAny.  That seems wrong, but it's a separate issue.

================
Comment at: lib/CodeGen/MicrosoftCXXABI.cpp:920
@@ +919,3 @@
+
+    if (RD->hasAttr<DLLImportAttr>())
+      VTable->setDLLStorageClass(llvm::GlobalValue::DLLImportStorageClass);
----------------
This should probably also go in getAddrOfVTable.  I wonder if that explains the MinGW issue.

================
Comment at: lib/CodeGen/MicrosoftCXXABI.cpp:1230
@@ -1220,1 +1229,3 @@
 
+  if (RD->hasAttr<DLLImportAttr>())
+    GV->setDLLStorageClass(llvm::GlobalValue::DLLImportStorageClass);
----------------
This should be in getAddrOfVBTable.  We might want to avoid emitting available externally vbtables at -O0 and simply import them from the dll.

================
Comment at: lib/Sema/SemaDeclCXX.cpp:4385
@@ +4384,3 @@
+    NewAttr->setInherited(true);
+    Member->addAttr(NewAttr);
+
----------------
We shouldn't be adding these attributes to FieldDecls.  I suppose we want to export nested classes, though.

http://reviews.llvm.org/D3877






More information about the cfe-commits mailing list