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
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;
}
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