Skip to content

Commit 99b5474

Browse files
committed
[Modules] Add test for merging of template member parent
This is a reduced test case originally meant to be addressed by https://reviews.llvm.org/D137787. It was recently fixed by commit 61c7a91 ("Commit to a primary definition for a class when we load its first member."), noting the difficulty to come up with a reduced test case. This setup with four modules seems to fail consistently before the fix mentioned above with an assertion in CGExprCXX.cpp, CodeGenFunction::EmitCXXDestructorCall(): Assertion `ThisTy->getAsCXXRecordDecl() == DtorDecl->getParent() && "Pointer/Object mixup"' failed. Differential Revision: https://reviews.llvm.org/D156806
1 parent f5b5a30 commit 99b5474

File tree

1 file changed

+64
-0
lines changed

1 file changed

+64
-0
lines changed
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
// RUN: rm -rf %t
2+
// RUN: mkdir %t
3+
// RUN: split-file %s %t
4+
5+
// RUN: %clang_cc1 -emit-obj -fmodules -fimplicit-module-maps -fmodules-cache-path=%t %t/merge.cpp -o %t/merge.o
6+
7+
//--- V.h
8+
#ifndef V_H
9+
#define V_H
10+
template <typename T>
11+
struct V {
12+
~V() {}
13+
};
14+
#endif
15+
16+
//--- A.h
17+
#include "V.h"
18+
19+
void A(const V<unsigned long> &v);
20+
21+
//--- B.h
22+
#include "V.h"
23+
24+
inline V<unsigned long> B() {
25+
return {};
26+
}
27+
28+
//--- C.h
29+
#include "V.h"
30+
31+
#include "A.h"
32+
33+
class C {
34+
public:
35+
C(const V<unsigned long> &v) {
36+
V<unsigned long> v2;
37+
}
38+
};
39+
40+
C GetC() {
41+
return {{}};
42+
}
43+
44+
// This include *MUST* come last.
45+
#include "B.h"
46+
47+
//--- module.modulemap
48+
module "V" { header "V.h" export * }
49+
module "A" { header "A.h" export * }
50+
module "B" { header "B.h" export * }
51+
module "C" { header "C.h" export * }
52+
53+
//--- merge.cpp
54+
#include "C.h"
55+
56+
template <typename T>
57+
C GetC_main() {
58+
return {{}};
59+
}
60+
61+
void f() {
62+
GetC_main<float>();
63+
GetC();
64+
}

0 commit comments

Comments
 (0)