Skip to content

Commit e34e00f

Browse files
authored
merge main into amd-staging (#569)
2 parents c1f09d1 + 518c02b commit e34e00f

File tree

119 files changed

+3007
-820
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

119 files changed

+3007
-820
lines changed

clang/lib/Serialization/ASTReader.cpp

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4087,10 +4087,14 @@ llvm::Error ASTReader::ReadASTBlock(ModuleFile &F,
40874087
std::errc::illegal_byte_sequence,
40884088
"Invalid PENDING_IMPLICIT_INSTANTIATIONS block");
40894089

4090-
for (unsigned I = 0, N = Record.size(); I != N; /* in loop */) {
4091-
PendingInstantiations.push_back(
4092-
{ReadDeclID(F, Record, I),
4093-
ReadSourceLocation(F, Record, I).getRawEncoding()});
4090+
// For standard C++20 module, we will only reads the instantiations
4091+
// if it is the main file.
4092+
if (!F.StandardCXXModule || F.Kind == MK_MainFile) {
4093+
for (unsigned I = 0, N = Record.size(); I != N; /* in loop */) {
4094+
PendingInstantiations.push_back(
4095+
{ReadDeclID(F, Record, I),
4096+
ReadSourceLocation(F, Record, I).getRawEncoding()});
4097+
}
40944098
}
40954099
break;
40964100

@@ -6438,10 +6442,13 @@ llvm::Error ASTReader::ReadSubmoduleBlock(ModuleFile &F,
64386442
case SUBMODULE_INITIALIZERS: {
64396443
if (!ContextObj)
64406444
break;
6441-
SmallVector<GlobalDeclID, 16> Inits;
6442-
for (unsigned I = 0; I < Record.size(); /*in loop*/)
6443-
Inits.push_back(ReadDeclID(F, Record, I));
6444-
ContextObj->addLazyModuleInitializers(CurrentModule, Inits);
6445+
// Standard C++ module has its own way to initialize variables.
6446+
if (!F.StandardCXXModule || F.Kind == MK_MainFile) {
6447+
SmallVector<GlobalDeclID, 16> Inits;
6448+
for (unsigned I = 0; I < Record.size(); /*in loop*/)
6449+
Inits.push_back(ReadDeclID(F, Record, I));
6450+
ContextObj->addLazyModuleInitializers(CurrentModule, Inits);
6451+
}
64456452
break;
64466453
}
64476454

clang/lib/Serialization/ASTWriter.cpp

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3247,7 +3247,7 @@ void ASTWriter::WriteSubmodules(Module *WritingModule, ASTContext *Context) {
32473247

32483248
// Emit the reachable initializers.
32493249
// The initializer may only be unreachable in reduced BMI.
3250-
if (Context) {
3250+
if (Context && !GeneratingReducedBMI) {
32513251
RecordData Inits;
32523252
for (Decl *D : Context->getModuleInitializers(Mod))
32533253
if (wasDeclEmitted(D))
@@ -5827,17 +5827,19 @@ void ASTWriter::WriteSpecialDeclRecords(Sema &SemaRef) {
58275827
Stream.EmitRecord(UNUSED_LOCAL_TYPEDEF_NAME_CANDIDATES,
58285828
UnusedLocalTypedefNameCandidates);
58295829

5830-
// Write the record containing pending implicit instantiations.
5831-
RecordData PendingInstantiations;
5832-
for (const auto &I : SemaRef.PendingInstantiations) {
5833-
if (!wasDeclEmitted(I.first))
5834-
continue;
5830+
if (!GeneratingReducedBMI) {
5831+
// Write the record containing pending implicit instantiations.
5832+
RecordData PendingInstantiations;
5833+
for (const auto &I : SemaRef.PendingInstantiations) {
5834+
if (!wasDeclEmitted(I.first))
5835+
continue;
58355836

5836-
AddDeclRef(I.first, PendingInstantiations);
5837-
AddSourceLocation(I.second, PendingInstantiations);
5837+
AddDeclRef(I.first, PendingInstantiations);
5838+
AddSourceLocation(I.second, PendingInstantiations);
5839+
}
5840+
if (!PendingInstantiations.empty())
5841+
Stream.EmitRecord(PENDING_IMPLICIT_INSTANTIATIONS, PendingInstantiations);
58385842
}
5839-
if (!PendingInstantiations.empty())
5840-
Stream.EmitRecord(PENDING_IMPLICIT_INSTANTIATIONS, PendingInstantiations);
58415843

58425844
// Write the record containing declaration references of Sema.
58435845
RecordData SemaDeclRefs;
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// RUN: rm -rf %t
2+
// RUN: split-file %s %t
3+
//
4+
// RUN: %clang_cc1 -std=c++20 %t/base.cppm -emit-module-interface -o %t/base.pcm
5+
// RUN: %clang_cc1 -std=c++20 %t/update.cppm -fmodule-file=base=%t/base.pcm -emit-module-interface -o %t/update.pcm
6+
// RUN: llvm-bcanalyzer --dump --disable-histogram %t/update.pcm | FileCheck %t/update.cppm --check-prefix=FULL
7+
//
8+
// RUN: %clang_cc1 -std=c++20 %t/base.cppm -emit-reduced-module-interface -o %t/base.pcm
9+
// RUN: %clang_cc1 -std=c++20 %t/update.cppm -fmodule-file=base=%t/base.pcm -emit-reduced-module-interface -o %t/update.pcm
10+
// RUN: llvm-bcanalyzer --dump --disable-histogram %t/update.pcm | FileCheck %t/update.cppm
11+
12+
//--- base.cppm
13+
export module base;
14+
15+
export template <typename T>
16+
struct base {
17+
T value;
18+
};
19+
20+
//--- update.cppm
21+
export module update;
22+
import base;
23+
export int update() {
24+
return base<int>().value;
25+
}
26+
27+
// FULL: TEMPLATE_SPECIALIZATION
28+
// CHECK-NOT: TEMPLATE_SPECIALIZATION

clang/test/Modules/pr166068.cppm

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
// RUN: rm -rf %t
2+
// RUN: mkdir -p %t
3+
// RUN: split-file %s %t
4+
//
5+
// RUN: %clang_cc1 -std=c++20 %t/flyweight.cppm -emit-reduced-module-interface -o %t/flyweight.pcm
6+
// RUN: %clang_cc1 -std=c++20 %t/account.cppm -emit-reduced-module-interface -o %t/account.pcm -fprebuilt-module-path=%t
7+
// RUN: %clang_cc1 -std=c++20 %t/core.cppm -emit-reduced-module-interface -o %t/core.pcm -fprebuilt-module-path=%t
8+
// RUN: %clang_cc1 -std=c++20 %t/core.cppm -fprebuilt-module-path=%t -emit-llvm -disable-llvm-passes -o - | FileCheck %t/core.cppm
9+
10+
//--- flyweight.cppm
11+
module;
12+
template <typename> struct flyweight_core {
13+
static bool init() { (void)__builtin_operator_new(2); return true; }
14+
static bool static_initializer;
15+
};
16+
template <typename T> bool flyweight_core<T>::static_initializer = init();
17+
export module flyweight;
18+
export template <class> void flyweight() {
19+
(void)flyweight_core<int>::static_initializer;
20+
}
21+
22+
//--- account.cppm
23+
export module account;
24+
import flyweight;
25+
export void account() {
26+
(void)::flyweight<int>;
27+
}
28+
29+
//--- core.cppm
30+
export module core;
31+
import account;
32+
33+
extern "C" void core() {}
34+
35+
// Fine enough to check it won't crash.
36+
// CHECK-NOT: init
37+
// CHECK-NOT: static_initializer
38+
// CHECK: define {{.*}}@core(

libcxx/docs/FeatureTestMacroTable.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -486,6 +486,8 @@ Status
486486
---------------------------------------------------------- -----------------
487487
``__cpp_lib_not_fn`` ``202306L``
488488
---------------------------------------------------------- -----------------
489+
``__cpp_lib_optional`` ``202506L``
490+
---------------------------------------------------------- -----------------
489491
``__cpp_lib_optional_range_support`` ``202406L``
490492
---------------------------------------------------------- -----------------
491493
``__cpp_lib_out_ptr`` ``202311L``

libcxx/docs/ReleaseNotes/22.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ Implemented Papers
4040

4141
- P2321R2: ``zip`` (`Github <https://llvm.org/PR105169>`__) (The paper is partially implemented. ``zip_transform_view``
4242
is implemented in this release)
43+
- P2988R12: ``std::optional<T&>`` (`Github <https://llvm.org/PR148131>`__)
4344
- P3044R2: sub-``string_view`` from ``string`` (`Github <https://llvm.org/PR148140>`__)
4445
- P3223R2: Making ``std::istream::ignore`` less surprising (`Github <https://llvm.org/PR148178>`__)
4546
- P3060R3: Add ``std::views::indices(n)`` (`Github <https://llvm.org/PR148175>`__)

libcxx/docs/Status/Cxx2cPapers.csv

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@
122122
"`P3293R3 <https://wg21.link/P3293R3>`__","Splicing a base class subobject","2025-06 (Sofia)","","","`#148125 <https://github.com/llvm/llvm-project/issues/148125>`__",""
123123
"`P3491R3 <https://wg21.link/P3491R3>`__","``define_static_{string,object,array}``","2025-06 (Sofia)","","","`#148126 <https://github.com/llvm/llvm-project/issues/148126>`__",""
124124
"`P3096R12 <https://wg21.link/P3096R12>`__","Function Parameter Reflection in Reflection for C++26","2025-06 (Sofia)","","","`#148127 <https://github.com/llvm/llvm-project/issues/148127>`__",""
125-
"`P2988R12 <https://wg21.link/P2988R12>`__","``std::optional<T&>``","2025-06 (Sofia)","","","`#148131 <https://github.com/llvm/llvm-project/issues/148131>`__",""
125+
"`P2988R12 <https://wg21.link/P2988R12>`__","``std::optional<T&>``","2025-06 (Sofia)","|Complete|","22","`#148131 <https://github.com/llvm/llvm-project/issues/148131>`__",""
126126
"`P3348R4 <https://wg21.link/P3348R4>`__","C++26 should refer to C23 not C17","2025-06 (Sofia)","","","`#148133 <https://github.com/llvm/llvm-project/issues/148133>`__",""
127127
"`P3037R6 <https://wg21.link/P3037R6>`__","``constexpr`` ``std::shared_ptr`` and friends","2025-06 (Sofia)","","","`#148135 <https://github.com/llvm/llvm-project/issues/148135>`__",""
128128
"`P3284R4 <https://wg21.link/P3284R4>`__","``write_env`` and ``unstoppable`` Sender Adaptors","2025-06 (Sofia)","","","`#148136 <https://github.com/llvm/llvm-project/issues/148136>`__",""

libcxx/include/__iterator/wrap_iter.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,8 @@ class __wrap_iter {
117117
friend class span;
118118
template <class _Tp, size_t _Size>
119119
friend struct array;
120-
template <class _Tp>
121-
friend class optional;
120+
template <class _Tp, class>
121+
friend struct __optional_iterator;
122122
};
123123

124124
template <class _Iter1>

0 commit comments

Comments
 (0)