]> granicus.if.org Git - clang/commitdiff
Merge r244488 to the 3.7 release branch
authorReid Kleckner <rnk@google.com>
Tue, 18 Aug 2015 23:18:57 +0000 (23:18 +0000)
committerReid Kleckner <rnk@google.com>
Tue, 18 Aug 2015 23:18:57 +0000 (23:18 +0000)
It avoids doing key function optimizations when the key function is
dllimported.

Fixed PR24409.

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

lib/AST/RecordLayoutBuilder.cpp
test/CodeGenCXX/dllimport-rtti.cpp

index 388c91c9cbc028fca06fd0342565ff264bb7b043..de7bcb826ebbcf04a425ac7267eef839eec8da28 100644 (file)
@@ -2014,6 +2014,12 @@ static const CXXMethodDecl *computeKeyFunction(ASTContext &Context,
         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;
   }
index f2d1bec95c0acc43417ac68cc639bbd86deecb7e..6fe67daa38d79b41d2e65495267ccc5b1275cb46 100644 (file)
@@ -20,3 +20,11 @@ struct __declspec(dllimport) V {
   virtual void f();
 } v;
 // GNU-DAG: @_ZTV1V = external dllimport
+
+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