Skip to content

Commit 7bb10f4

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

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
@@ -10182,12 +10182,12 @@ void ASTReader::visitTopLevelModuleMaps(
1018210182
}
1018310183

1018410184
void ASTReader::finishPendingActions() {
10185-
while (
10186-
!PendingIdentifierInfos.empty() || !PendingDeducedFunctionTypes.empty() ||
10187-
!PendingDeducedVarTypes.empty() || !PendingIncompleteDeclChains.empty() ||
10188-
!PendingDeclChains.empty() || !PendingMacroIDs.empty() ||
10189-
!PendingDeclContextInfos.empty() || !PendingUpdateRecords.empty() ||
10190-
!PendingObjCExtensionIvarRedeclarations.empty()) {
10185+
while (!PendingIdentifierInfos.empty() ||
10186+
!PendingDeducedFunctionTypes.empty() ||
10187+
!PendingDeducedVarTypes.empty() || !PendingDeclChains.empty() ||
10188+
!PendingMacroIDs.empty() || !PendingDeclContextInfos.empty() ||
10189+
!PendingUpdateRecords.empty() ||
10190+
!PendingObjCExtensionIvarRedeclarations.empty()) {
1019110191
// If any identifiers with corresponding top-level declarations have
1019210192
// been loaded, load those declarations now.
1019310193
using TopLevelDeclsMap =
@@ -10235,13 +10235,6 @@ void ASTReader::finishPendingActions() {
1023510235
}
1023610236
PendingDeducedVarTypes.clear();
1023710237

10238-
// For each decl chain that we wanted to complete while deserializing, mark
10239-
// it as "still needs to be completed".
10240-
for (unsigned I = 0; I != PendingIncompleteDeclChains.size(); ++I) {
10241-
markIncompleteDeclChain(PendingIncompleteDeclChains[I]);
10242-
}
10243-
PendingIncompleteDeclChains.clear();
10244-
1024510238
// Load pending declaration chains.
1024610239
for (unsigned I = 0; I != PendingDeclChains.size(); ++I)
1024710240
loadPendingDeclChain(PendingDeclChains[I].first,
@@ -10479,6 +10472,12 @@ void ASTReader::finishPendingActions() {
1047910472
for (auto *ND : PendingMergedDefinitionsToDeduplicate)
1048010473
getContext().deduplicateMergedDefinitonsFor(ND);
1048110474
PendingMergedDefinitionsToDeduplicate.clear();
10475+
10476+
// For each decl chain that we wanted to complete while deserializing, mark
10477+
// it as "still needs to be completed".
10478+
for (Decl *D : PendingIncompleteDeclChains)
10479+
markIncompleteDeclChain(D);
10480+
PendingIncompleteDeclChains.clear();
1048210481
}
1048310482

1048410483
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)