Skip to content

Commit 3f88306

Browse files
committed
Reapply "[C++20][Modules][Serialization] Delay marking pending incompl… (llvm#127136)
This reverts commit 912b154.
1 parent a216358 commit 3f88306

File tree

2 files changed

+105
-13
lines changed

2 files changed

+105
-13
lines changed

clang/lib/Serialization/ASTReader.cpp

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10178,12 +10178,12 @@ void ASTReader::visitTopLevelModuleMaps(
1017810178
}
1017910179

1018010180
void ASTReader::finishPendingActions() {
10181-
while (
10182-
!PendingIdentifierInfos.empty() || !PendingDeducedFunctionTypes.empty() ||
10183-
!PendingDeducedVarTypes.empty() || !PendingIncompleteDeclChains.empty() ||
10184-
!PendingDeclChains.empty() || !PendingMacroIDs.empty() ||
10185-
!PendingDeclContextInfos.empty() || !PendingUpdateRecords.empty() ||
10186-
!PendingObjCExtensionIvarRedeclarations.empty()) {
10181+
while (!PendingIdentifierInfos.empty() ||
10182+
!PendingDeducedFunctionTypes.empty() ||
10183+
!PendingDeducedVarTypes.empty() || !PendingDeclChains.empty() ||
10184+
!PendingMacroIDs.empty() || !PendingDeclContextInfos.empty() ||
10185+
!PendingUpdateRecords.empty() ||
10186+
!PendingObjCExtensionIvarRedeclarations.empty()) {
1018710187
// If any identifiers with corresponding top-level declarations have
1018810188
// been loaded, load those declarations now.
1018910189
using TopLevelDeclsMap =
@@ -10231,13 +10231,6 @@ void ASTReader::finishPendingActions() {
1023110231
}
1023210232
PendingDeducedVarTypes.clear();
1023310233

10234-
// For each decl chain that we wanted to complete while deserializing, mark
10235-
// it as "still needs to be completed".
10236-
for (unsigned I = 0; I != PendingIncompleteDeclChains.size(); ++I) {
10237-
markIncompleteDeclChain(PendingIncompleteDeclChains[I]);
10238-
}
10239-
PendingIncompleteDeclChains.clear();
10240-
1024110234
// Load pending declaration chains.
1024210235
for (unsigned I = 0; I != PendingDeclChains.size(); ++I)
1024310236
loadPendingDeclChain(PendingDeclChains[I].first,
@@ -10475,6 +10468,12 @@ void ASTReader::finishPendingActions() {
1047510468
for (auto *ND : PendingMergedDefinitionsToDeduplicate)
1047610469
getContext().deduplicateMergedDefinitonsFor(ND);
1047710470
PendingMergedDefinitionsToDeduplicate.clear();
10471+
10472+
// For each decl chain that we wanted to complete while deserializing, mark
10473+
// it as "still needs to be completed".
10474+
for (Decl *D : PendingIncompleteDeclChains)
10475+
markIncompleteDeclChain(D);
10476+
PendingIncompleteDeclChains.clear();
1047810477
}
1047910478

1048010479
void ASTReader::diagnoseOdrViolations() {

clang/test/Modules/pr121245.cpp

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

0 commit comments

Comments
 (0)