Skip to content

Commit 4790194

Browse files
committedDec 15, 2018
[MinGW] Produce a vtable and RTTI for dllexported classes without a key function
This matches what GCC does in these situations. This fixes compiling Qt in debug mode. In release mode, references to the vtable of this particular class ends up optimized away, but in debug mode, the compiler creates references to the vtable, which is expected to be dllexported from a different DLL. Make sure the dllexported version actually ends up emitted. Differential Revision: https://reviews.llvm.org/D55698 llvm-svn: 349256
1 parent a53bb3a commit 4790194

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed
 

‎clang/lib/Sema/SemaDeclCXX.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -5528,6 +5528,9 @@ static void ReferenceDllExportedMembers(Sema &S, CXXRecordDecl *Class) {
55285528
// declaration.
55295529
return;
55305530

5531+
if (S.Context.getTargetInfo().getTriple().isWindowsGNUEnvironment())
5532+
S.MarkVTableUsed(Class->getLocation(), Class, true);
5533+
55315534
for (Decl *Member : Class->decls()) {
55325535
// Defined static variables that are members of an exported base
55335536
// class must be marked export too.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// RUN: %clang_cc1 -triple x86_64-windows-gnu -emit-llvm -std=c++11 -o - %s | FileCheck --check-prefix=GNU %s
2+
3+
class __declspec(dllexport) QAbstractLayoutStyleInfo {
4+
public:
5+
QAbstractLayoutStyleInfo() : m_isWindow(false) {}
6+
virtual ~QAbstractLayoutStyleInfo() {}
7+
8+
virtual bool hasChangedCore() const { return false; }
9+
10+
virtual void invalidate() {}
11+
12+
virtual double windowMargin(bool orientation) const = 0;
13+
14+
bool isWindow() const { return m_isWindow; }
15+
16+
protected:
17+
bool m_isWindow;
18+
};
19+
20+
// GNU-DAG: @_ZTV24QAbstractLayoutStyleInfo = weak_odr dso_local dllexport
21+
// GNU-DAG: @_ZTS24QAbstractLayoutStyleInfo = linkonce_odr
22+
// GNU-DAG: @_ZTI24QAbstractLayoutStyleInfo = linkonce_odr

0 commit comments

Comments
 (0)