[PATCH] D11913: [dllimport] A non-imported class with an imported key can't have a key

Reid Kleckner via cfe-commits cfe-commits at lists.llvm.org
Mon Aug 10 12:39:50 PDT 2015


This revision was automatically updated to reflect the committed changes.
Closed by commit rL244488: [dllimport] A non-imported class with an imported key can't have a key (authored by rnk).

Changed prior to commit:
  http://reviews.llvm.org/D11913?vs=31697&id=31710#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D11913

Files:
  cfe/trunk/lib/AST/RecordLayoutBuilder.cpp
  cfe/trunk/test/CodeGenCXX/dllimport-rtti.cpp

Index: cfe/trunk/test/CodeGenCXX/dllimport-rtti.cpp
===================================================================
--- cfe/trunk/test/CodeGenCXX/dllimport-rtti.cpp
+++ cfe/trunk/test/CodeGenCXX/dllimport-rtti.cpp
@@ -22,3 +22,11 @@
 // GNU-DAG: @_ZTV1V = available_externally dllimport
 // GNU-DAG: @_ZTS1V = linkonce_odr
 // GNU-DAG: @_ZTI1V = linkonce_odr
+
+struct W {
+  __declspec(dllimport) virtual void f();
+  virtual void g();
+} w;
+// GNU-DAG: @_ZTV1W = linkonce_odr
+// GNU-DAG: @_ZTS1W = linkonce_odr
+// GNU-DAG: @_ZTI1W = linkonce_odr
Index: cfe/trunk/lib/AST/RecordLayoutBuilder.cpp
===================================================================
--- cfe/trunk/lib/AST/RecordLayoutBuilder.cpp
+++ cfe/trunk/lib/AST/RecordLayoutBuilder.cpp
@@ -2008,6 +2008,12 @@
         continue;
     }
 
+    // If the key function is dllimport but the class isn't, then the class has
+    // no key function. The DLL that exports the key function won't export the
+    // vtable in this case.
+    if (MD->hasAttr<DLLImportAttr>() && !RD->hasAttr<DLLImportAttr>())
+      return nullptr;
+
     // We found it.
     return MD;
   }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D11913.31710.patch
Type: text/x-patch
Size: 1144 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20150810/8d05aaa1/attachment.bin>


More information about the cfe-commits mailing list