]> granicus.if.org Git - clang/commitdiff
Merge r244266 to the 3.7 release branch
authorReid Kleckner <rnk@google.com>
Tue, 18 Aug 2015 23:16:47 +0000 (23:16 +0000)
committerReid Kleckner <rnk@google.com>
Tue, 18 Aug 2015 23:16:47 +0000 (23:16 +0000)
It's actually probably a no-op, since the 3.7 branch will not generate
available externally vtables.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/branches/release_37@245387 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/ItaniumCXXABI.cpp
test/CodeGenCXX/dllimport-rtti.cpp

index 70af69b76457c5f6d2eb5d995820e515f70f85e4..2be9ceb1d637d2d0f220e8ec6f87efc7e7ade3e6 100644 (file)
@@ -2420,10 +2420,13 @@ static bool ShouldUseExternalRTTIDescriptor(CodeGenModule &CGM,
 
     // FIXME: this may need to be reconsidered if the key function
     // changes.
+    // N.B. We must always emit the RTTI data ourselves if there exists a key
+    // function.
+    bool IsDLLImport = RD->hasAttr<DLLImportAttr>();
     if (CGM.getVTables().isVTableExternal(RD))
-      return true;
+      return IsDLLImport ? false : true;
 
-    if (RD->hasAttr<DLLImportAttr>())
+    if (IsDLLImport)
       return true;
   }
 
@@ -2653,8 +2656,15 @@ static llvm::GlobalVariable::LinkageTypes getTypeInfoLinkage(CodeGenModule &CGM,
       const CXXRecordDecl *RD = cast<CXXRecordDecl>(Record->getDecl());
       if (RD->hasAttr<WeakAttr>())
         return llvm::GlobalValue::WeakODRLinkage;
-      if (RD->isDynamicClass())
-        return CGM.getVTableLinkage(RD);
+      if (RD->isDynamicClass()) {
+        llvm::GlobalValue::LinkageTypes LT = CGM.getVTableLinkage(RD);
+        // MinGW won't export the RTTI information when there is a key function.
+        // Make sure we emit our own copy instead of attempting to dllimport it.
+        if (RD->hasAttr<DLLImportAttr>() &&
+            llvm::GlobalValue::isAvailableExternallyLinkage(LT))
+          LT = llvm::GlobalValue::LinkOnceODRLinkage;
+        return LT;
+      }
     }
 
     return llvm::GlobalValue::LinkOnceODRLinkage;
index 8c0f86306cde0cff257df88c8c230b353c3af5f5..f2d1bec95c0acc43417ac68cc639bbd86deecb7e 100644 (file)
@@ -15,3 +15,8 @@ struct __declspec(dllimport) S {
 
 struct U : S {
 } u;
+
+struct __declspec(dllimport) V {
+  virtual void f();
+} v;
+// GNU-DAG: @_ZTV1V = external dllimport