diff --git a/clang/lib/Serialization/ASTWriter.cpp b/clang/lib/Serialization/ASTWriter.cpp index d99d85652c7b..5b39055cf9f2 100644 --- a/clang/lib/Serialization/ASTWriter.cpp +++ b/clang/lib/Serialization/ASTWriter.cpp @@ -5387,6 +5387,17 @@ ASTFileSignature ASTWriter::WriteASTCore(Sema &SemaRef, StringRef isysroot, } } + // Form the record of special types. + RecordData SpecialTypes; + AddTypeRef(Context.getRawCFConstantStringType(), SpecialTypes); + AddTypeRef(Context.getFILEType(), SpecialTypes); + AddTypeRef(Context.getjmp_bufType(), SpecialTypes); + AddTypeRef(Context.getsigjmp_bufType(), SpecialTypes); + AddTypeRef(Context.ObjCIdRedefinitionType, SpecialTypes); + AddTypeRef(Context.ObjCClassRedefinitionType, SpecialTypes); + AddTypeRef(Context.ObjCSelRedefinitionType, SpecialTypes); + AddTypeRef(Context.getucontext_tType(), SpecialTypes); + PrepareWritingSpecialDecls(SemaRef); // Write the control block @@ -5418,17 +5429,6 @@ ASTFileSignature ASTWriter::WriteASTCore(Sema &SemaRef, StringRef isysroot, for (auto &Selector : AllSelectors) SemaRef.ObjC().updateOutOfDateSelector(Selector); - // Form the record of special types. - RecordData SpecialTypes; - AddTypeRef(Context.getRawCFConstantStringType(), SpecialTypes); - AddTypeRef(Context.getFILEType(), SpecialTypes); - AddTypeRef(Context.getjmp_bufType(), SpecialTypes); - AddTypeRef(Context.getsigjmp_bufType(), SpecialTypes); - AddTypeRef(Context.ObjCIdRedefinitionType, SpecialTypes); - AddTypeRef(Context.ObjCClassRedefinitionType, SpecialTypes); - AddTypeRef(Context.ObjCSelRedefinitionType, SpecialTypes); - AddTypeRef(Context.getucontext_tType(), SpecialTypes); - if (Chain) { // Write the mapping information describing our module dependencies and how // each of those modules were mapped into our own offset/ID space, so that diff --git a/clang/test/Modules/no-implicit-declarations.cppm b/clang/test/Modules/no-implicit-declarations.cppm index 79c3c5e76f63..a5129d40194d 100644 --- a/clang/test/Modules/no-implicit-declarations.cppm +++ b/clang/test/Modules/no-implicit-declarations.cppm @@ -16,11 +16,11 @@ export int a = 43; // CHECK: diff --git a/clang/test/Modules/no-transitive-decl-change-2.cppm b/clang/test/Modules/no-transitive-decl-change-2.cppm new file mode 100644 index 000000000000..fe29d9169201 --- /dev/null +++ b/clang/test/Modules/no-transitive-decl-change-2.cppm @@ -0,0 +1,28 @@ +// Test that adding a new unused decl within reduced BMI may not produce a transitive change. +// +// RUN: rm -rf %t +// RUN: split-file %s %t +// +// RUN: %clang_cc1 -std=c++20 -emit-reduced-module-interface %t/A.cppm -o %t/A.pcm +// RUN: %clang_cc1 -std=c++20 -emit-reduced-module-interface %t/B.cppm -o %t/B.pcm \ +// RUN: -fmodule-file=A=%t/A.pcm +// +// RUN: %clang_cc1 -std=c++20 -emit-reduced-module-interface %t/A.v1.cppm -o %t/A.v1.pcm +// RUN: %clang_cc1 -std=c++20 -emit-reduced-module-interface %t/B.cppm -o %t/B.v1.pcm \ +// RUN: -fmodule-file=A=%t/A.v1.pcm +// +// RUN: diff %t/B.pcm %t/B.v1.pcm &> /dev/null + +//--- A.cppm +export module A; +export int a() { return 44; } + +//--- A.v1.cppm +export module A; +int a_impl() { return 48; } +export int a() { return a_impl(); } + +//--- B.cppm +export module B; +import A; +export int b() { return a(); }