File tree Expand file tree Collapse file tree 2 files changed +37
-2
lines changed Expand file tree Collapse file tree 2 files changed +37
-2
lines changed Original file line number Diff line number Diff line change @@ -5037,6 +5037,14 @@ void ASTWriter::PrepareWritingSpecialDecls(Sema &SemaRef) {
5037
5037
continue ;
5038
5038
}
5039
5039
5040
+ // If we're writing C++ named modules, don't emit declarations which are
5041
+ // not from modules by default. They may be built in declarations (be
5042
+ // handled above) or implcit declarations (see the implementation of
5043
+ // `Sema::Initialize()` for example).
5044
+ if (isWritingStdCXXNamedModules () && !D->getOwningModule () &&
5045
+ D->isImplicit ())
5046
+ continue ;
5047
+
5040
5048
GetDeclRef (D);
5041
5049
}
5042
5050
@@ -6197,8 +6205,9 @@ bool ASTWriter::wasDeclEmitted(const Decl *D) const {
6197
6205
return true ;
6198
6206
6199
6207
bool Emitted = DeclIDs.contains (D);
6200
- assert ((Emitted || GeneratingReducedBMI) &&
6201
- " The declaration can only be omitted in reduced BMI." );
6208
+ assert ((Emitted || (!D->getOwningModule () && isWritingStdCXXNamedModules ()) ||
6209
+ GeneratingReducedBMI) &&
6210
+ " The declaration within modules can only be omitted in reduced BMI." );
6202
6211
return Emitted;
6203
6212
}
6204
6213
Original file line number Diff line number Diff line change
1
+ // RUN: rm -rf %t
2
+ // RUN: mkdir %t
3
+ //
4
+ // RUN: %clang_cc1 -std=c++20 %s -emit-module-interface -o %t/a.pcm
5
+ // RUN: llvm-bcanalyzer --dump --disable-histogram --show-binary-blobs %t/a.pcm > %t/a.dump
6
+ // RUN: cat %t/a.dump | FileCheck %s
7
+ //
8
+ // RUN: %clang_cc1 -std=c++20 %s -emit-reduced-module-interface -o %t/a.pcm
9
+ // RUN: llvm-bcanalyzer --dump --disable-histogram --show-binary-blobs %t/a.pcm > %t/a.dump
10
+ // RUN: cat %t/a.dump | FileCheck %s
11
+
12
+ export module a;
13
+ // Contain something at least to make sure the compiler won't
14
+ // optimize this out.
15
+ export int a = 43 ;
16
+
17
+ // CHECK: <DECLTYPES_BLOCK
18
+ // CHECK-NOT: <DECL_TYPEDEF
19
+ // CHECK: <DECL_CONTEXT_LEXICAL
20
+ // CHECK: <UnknownCode
21
+ // CHECK: <TYPE_TYPEDEF
22
+ // CHECK: <DECL_VAR
23
+ // CHECK: <EXPR_INTEGER_LITERAL
24
+ // CHECK: <STMT_STOP
25
+ // CHECK: <TYPE_RECORD
26
+ // CHECK: </DECLTYPES_BLOCK>
You can’t perform that action at this time.
0 commit comments