[clang] [C++20] [Modules] Fix incorrect read of TULocalOffset for delayed namespace (PR #174365)
via cfe-commits
cfe-commits at lists.llvm.org
Sun Jan 4 22:47:50 PST 2026
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang-modules
Author: Chuanqi Xu (ChuanqiXu9)
<details>
<summary>Changes</summary>
Close https://github.com/llvm/llvm-project/issues/158321
The root cause of the problem is a mismatch in an initializer.
---
Full diff: https://github.com/llvm/llvm-project/pull/174365.diff
2 Files Affected:
- (modified) clang/lib/Serialization/ASTReader.cpp (+1-1)
- (added) clang/test/Modules/pr158321.cppm (+27)
``````````diff
diff --git a/clang/lib/Serialization/ASTReader.cpp b/clang/lib/Serialization/ASTReader.cpp
index e518c5cca32bb..540373cebdfc6 100644
--- a/clang/lib/Serialization/ASTReader.cpp
+++ b/clang/lib/Serialization/ASTReader.cpp
@@ -4223,7 +4223,7 @@ llvm::Error ASTReader::ReadASTBlock(ModuleFile &F,
TULocalLocalOffset ? BaseOffset + TULocalLocalOffset : 0;
DelayedNamespaceOffsetMap[ID] = {
- {VisibleOffset, TULocalOffset, ModuleLocalOffset}, LexicalOffset};
+ {VisibleOffset, ModuleLocalOffset, TULocalOffset}, LexicalOffset};
assert(!GetExistingDecl(ID) &&
"We shouldn't load the namespace in the front of delayed "
diff --git a/clang/test/Modules/pr158321.cppm b/clang/test/Modules/pr158321.cppm
new file mode 100644
index 0000000000000..e5be1769c04a6
--- /dev/null
+++ b/clang/test/Modules/pr158321.cppm
@@ -0,0 +1,27 @@
+// RUN: rm -rf %t
+// RUN: mkdir -p %t
+// RUN: split-file %s %t
+//
+// RUN: %clang_cc1 -std=c++20 %t/m.cppm -emit-reduced-module-interface -o %t/m.pcm
+// RUN: %clang_cc1 -std=c++20 %t/consumer.cpp -fprebuilt-module-path=%t -fsyntax-only -verify
+
+//--- repro_header.h
+namespace n
+{
+}
+
+//--- m.cppm
+module;
+#include "repro_header.h"
+export module m;
+namespace n
+{
+ int x;
+}
+
+//--- consumer.cpp
+// expected-no-diagnostics
+import m;
+namespace n
+{
+}
\ No newline at end of file
``````````
</details>
https://github.com/llvm/llvm-project/pull/174365
More information about the cfe-commits
mailing list