[Serialization] Register Speical types before register decls
We will only regsiter top level types and decls in ASTWriter and we will register the sub types and decls during the process of writing types and decls. So that the ID for the types in the sub level can be different if the writing decl process changes the order of the to-be- emitted type queues. This is not ideal since it causes unnecessary changes especially in no transitive changes model. This patch migrates the issue by regsitering special types before regsitering decls. This make sure that the special types in the 2nd top level can be registered early than the decls. But it might still be problematic if there are more levels in the special types. Luckily we just don't have such special types.
This commit is contained in:
parent
8f49dab19e
commit
1ecc5ae13b
@ -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
|
||||
|
||||
@ -16,11 +16,11 @@ export int a = 43;
|
||||
|
||||
// CHECK: <DECLTYPES_BLOCK
|
||||
// CHECK-NOT: <DECL_TYPEDEF
|
||||
// CHECK: <TYPE_TYPEDEF
|
||||
// CHECK: <DECL_CONTEXT_LEXICAL
|
||||
// CHECK: <DECL_EXPORT
|
||||
// CHECK: <TYPE_TYPEDEF
|
||||
// CHECK: <TYPE_RECORD
|
||||
// CHECK: <DECL_VAR
|
||||
// CHECK: <EXPR_INTEGER_LITERAL
|
||||
// CHECK: <STMT_STOP
|
||||
// CHECK: <TYPE_RECORD
|
||||
// CHECK: </DECLTYPES_BLOCK>
|
||||
|
||||
28
clang/test/Modules/no-transitive-decl-change-2.cppm
Normal file
28
clang/test/Modules/no-transitive-decl-change-2.cppm
Normal file
@ -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(); }
|
||||
Loading…
x
Reference in New Issue
Block a user