Skip to content

Commit 9879eb1

Browse files
committed
Delay marking pending incomplete decl chains until the end of finishPendingActions.
1 parent d4159e2 commit 9879eb1

File tree

2 files changed

+103
-13
lines changed

2 files changed

+103
-13
lines changed

clang/lib/Serialization/ASTReader.cpp

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10186,12 +10186,12 @@ void ASTReader::visitTopLevelModuleMaps(
1018610186
}
1018710187

1018810188
void ASTReader::finishPendingActions() {
10189-
while (
10190-
!PendingIdentifierInfos.empty() || !PendingDeducedFunctionTypes.empty() ||
10191-
!PendingDeducedVarTypes.empty() || !PendingIncompleteDeclChains.empty() ||
10192-
!PendingDeclChains.empty() || !PendingMacroIDs.empty() ||
10193-
!PendingDeclContextInfos.empty() || !PendingUpdateRecords.empty() ||
10194-
!PendingObjCExtensionIvarRedeclarations.empty()) {
10189+
while (!PendingIdentifierInfos.empty() ||
10190+
!PendingDeducedFunctionTypes.empty() ||
10191+
!PendingDeducedVarTypes.empty() || !PendingDeclChains.empty() ||
10192+
!PendingMacroIDs.empty() || !PendingDeclContextInfos.empty() ||
10193+
!PendingUpdateRecords.empty() ||
10194+
!PendingObjCExtensionIvarRedeclarations.empty()) {
1019510195
// If any identifiers with corresponding top-level declarations have
1019610196
// been loaded, load those declarations now.
1019710197
using TopLevelDeclsMap =
@@ -10239,13 +10239,6 @@ void ASTReader::finishPendingActions() {
1023910239
}
1024010240
PendingDeducedVarTypes.clear();
1024110241

10242-
// For each decl chain that we wanted to complete while deserializing, mark
10243-
// it as "still needs to be completed".
10244-
for (unsigned I = 0; I != PendingIncompleteDeclChains.size(); ++I) {
10245-
markIncompleteDeclChain(PendingIncompleteDeclChains[I]);
10246-
}
10247-
PendingIncompleteDeclChains.clear();
10248-
1024910242
// Load pending declaration chains.
1025010243
for (unsigned I = 0; I != PendingDeclChains.size(); ++I)
1025110244
loadPendingDeclChain(PendingDeclChains[I].first,
@@ -10483,6 +10476,13 @@ void ASTReader::finishPendingActions() {
1048310476
for (auto *ND : PendingMergedDefinitionsToDeduplicate)
1048410477
getContext().deduplicateMergedDefinitonsFor(ND);
1048510478
PendingMergedDefinitionsToDeduplicate.clear();
10479+
10480+
// For each decl chain that we wanted to complete while deserializing, mark
10481+
// it as "still needs to be completed".
10482+
for (unsigned I = 0; I != PendingIncompleteDeclChains.size(); ++I) {
10483+
markIncompleteDeclChain(PendingIncompleteDeclChains[I]);
10484+
}
10485+
PendingIncompleteDeclChains.clear();
1048610486
}
1048710487

1048810488
void ASTReader::diagnoseOdrViolations() {

clang/test/Modules/pr121245.cpp

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
// RUN: rm -rf %t
2+
// RUN: mkdir -p %t
3+
// RUN: split-file %s %t
4+
// RUN: cd %t
5+
6+
// RUN: %clang_cc1 -std=c++20 -emit-header-unit -xc++-user-header %t/hu-01.h \
7+
// RUN: -fcxx-exceptions -o %t/hu-01.pcm
8+
9+
// RUN: %clang_cc1 -std=c++20 -emit-header-unit -xc++-user-header %t/hu-02.h \
10+
// RUN: -Wno-experimental-header-units -fcxx-exceptions \
11+
// RUN: -fmodule-file=%t/hu-01.pcm -o %t/hu-02.pcm
12+
13+
// RUN: %clang_cc1 -std=c++20 -emit-header-unit -xc++-user-header %t/hu-03.h \
14+
// RUN: -Wno-experimental-header-units -fcxx-exceptions \
15+
// RUN: -fmodule-file=%t/hu-01.pcm -o %t/hu-03.pcm
16+
17+
// RUN: %clang_cc1 -std=c++20 -emit-header-unit -xc++-user-header %t/hu-04.h \
18+
// RUN: -Wno-experimental-header-units -fcxx-exceptions \
19+
// RUN: -fmodule-file=%t/hu-01.pcm -o %t/hu-04.pcm
20+
21+
// RUN: %clang_cc1 -std=c++20 -emit-header-unit -xc++-user-header %t/hu-05.h \
22+
// RUN: -Wno-experimental-header-units -fcxx-exceptions \
23+
// RUN: -fmodule-file=%t/hu-03.pcm -fmodule-file=%t/hu-04.pcm \
24+
// RUN: -fmodule-file=%t/hu-01.pcm -o %t/hu-05.pcm
25+
26+
// RUN: %clang_cc1 -std=c++20 -emit-obj %t/main.cpp \
27+
// RUN: -Wno-experimental-header-units -fcxx-exceptions \
28+
// RUN: -fmodule-file=%t/hu-02.pcm -fmodule-file=%t/hu-05.pcm \
29+
// RUN: -fmodule-file=%t/hu-04.pcm -fmodule-file=%t/hu-03.pcm \
30+
// RUN: -fmodule-file=%t/hu-01.pcm
31+
32+
//--- hu-01.h
33+
template <typename T>
34+
struct A {
35+
A() {}
36+
~A() {}
37+
};
38+
39+
template <typename T>
40+
struct EBO : T {
41+
EBO() = default;
42+
};
43+
44+
template <typename T>
45+
struct HT : EBO<A<T>> {};
46+
47+
//--- hu-02.h
48+
import "hu-01.h";
49+
50+
inline void f() {
51+
HT<int>();
52+
}
53+
54+
//--- hu-03.h
55+
import "hu-01.h";
56+
57+
struct C {
58+
C();
59+
60+
HT<long> _;
61+
};
62+
63+
//--- hu-04.h
64+
import "hu-01.h";
65+
66+
void g(HT<long> = {});
67+
68+
//--- hu-05.h
69+
import "hu-03.h";
70+
import "hu-04.h";
71+
import "hu-01.h";
72+
73+
struct B {
74+
virtual ~B() = default;
75+
76+
virtual void f() {
77+
HT<long>();
78+
}
79+
};
80+
81+
//--- main.cpp
82+
import "hu-02.h";
83+
import "hu-05.h";
84+
import "hu-03.h";
85+
86+
int main() {
87+
f();
88+
C();
89+
B();
90+
}

0 commit comments

Comments
 (0)