Skip to content

Commit 279c7a2

Browse files
committed
Revert "[C++20] [Modules] Don't load declaration eagerly for named modules"
This reverts commit af86957. Close #61733. Previously I banned the eagerly loading for declarations from named modules to speedup the process of reading modules. But I didn't think about special decls like PragmaCommentDecl and PragmaDetectMismatchDecl. So here is the issue #61733. Note that the current behavior is still incorrect. Given: ``` // mod.cppm module; export module mod; ``` and ``` // user.cpp import mod; ``` Now the IR of `user.cpp` will contain the metadata '!0 = !{!"msvcprt.lib"}' incorrectly. The root cause of the problem is that `EagerlyDeserializedDecls` is designed for headers and it didn't take care for named modules. We need to redesign a new mechanism for named modules.
1 parent 766d048 commit 279c7a2

File tree

2 files changed

+1
-117
lines changed

2 files changed

+1
-117
lines changed

clang/lib/Serialization/ASTWriterDecl.cpp

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2468,13 +2468,7 @@ void ASTWriter::WriteDeclAbbrevs() {
24682468
/// relatively painless since they would presumably only do it for top-level
24692469
/// decls.
24702470
static bool isRequiredDecl(const Decl *D, ASTContext &Context,
2471-
Module *WritingModule) {
2472-
// Named modules have different semantics than header modules. Every named
2473-
// module units owns a translation unit. So the importer of named modules
2474-
// doesn't need to deserilize everything ahead of time.
2475-
if (WritingModule && WritingModule->isModulePurview())
2476-
return false;
2477-
2471+
bool WritingModule) {
24782472
// An ObjCMethodDecl is never considered as "required" because its
24792473
// implementation container always is.
24802474

clang/test/Modules/no-eager-load.cppm

Lines changed: 0 additions & 110 deletions
This file was deleted.

0 commit comments

Comments
 (0)