Index: lib/CodeGen/CGVTables.cpp =================================================================== --- lib/CodeGen/CGVTables.cpp +++ lib/CodeGen/CGVTables.cpp @@ -884,6 +884,9 @@ if (CGM.getTarget().getCXXABI().isMicrosoft()) return false; + if (CGM.getTriple().isWindowsGNUEnvironment() && RD->hasAttr()) + return true; + // If we have an explicit instantiation declaration (and not a // definition), the vtable is defined elsewhere. TemplateSpecializationKind TSK = RD->getTemplateSpecializationKind(); Index: test/CodeGenCXX/dllimport-missing-key.cpp =================================================================== --- /dev/null +++ test/CodeGenCXX/dllimport-missing-key.cpp @@ -0,0 +1,20 @@ +// RUN: %clang_cc1 -triple i686-windows-gnu -emit-llvm -std=c++1y -O0 -o - %s -w | FileCheck --check-prefix=GNU %s + +class __declspec(dllimport) QObjectData { +public: + virtual ~QObjectData() = 0; + void *ptr; + + int method() const; +}; + +class LocalClass : public QObjectData { +}; + +void call() { + (new LocalClass())->method(); +} + +// GNU-DAG: @_ZTV11QObjectData = external dllimport +// GNU-DAG: @_ZTS11QObjectData = linkonce_odr +// GNU-DAG: @_ZTI11QObjectData = linkonce_odr Index: test/CodeGenCXX/dllimport-rtti.cpp =================================================================== --- test/CodeGenCXX/dllimport-rtti.cpp +++ test/CodeGenCXX/dllimport-rtti.cpp @@ -12,7 +12,7 @@ // MSVC-DAG: @"\01??_R3S@@8" = linkonce_odr // GNU-DAG: @_ZTV1S = available_externally dllimport -// GNU-DAG: @_ZTI1S = external dllimport +// GNU-DAG: @_ZTI1S = linkonce_odr struct U : S { } u; Index: test/CodeGenCXX/dllimport.cpp =================================================================== --- test/CodeGenCXX/dllimport.cpp +++ test/CodeGenCXX/dllimport.cpp @@ -658,7 +658,7 @@ USECLASS(W) // vftable: // MO1-DAG: @"\01??_SW@@6B@" = linkonce_odr unnamed_addr constant { [1 x i8*] } { [1 x i8*] [i8* bitcast (void (%struct.W*)* @"\01?foo@W@@UAEXXZ" to i8*)] } -// GO1-DAG: @_ZTV1W = available_externally dllimport unnamed_addr constant { [3 x i8*] } { [3 x i8*] [i8* null, i8* null, i8* bitcast (void (%struct.W*)* @_ZN1W3fooEv to i8*)] } +// GO1-DAG: @_ZTV1W = external dllimport unnamed_addr constant { [3 x i8*] } struct __declspec(dllimport) KeyFuncClass { constexpr KeyFuncClass() {}