[clang] 4b35dd5 - [Serialization] Try to clean up PendingUndeducedFunctionDecls when

Chuanqi Xu via cfe-commits cfe-commits at lists.llvm.org
Sun Dec 22 23:14:56 PST 2024


Author: Chuanqi Xu
Date: 2024-12-23T15:14:38+08:00
New Revision: 4b35dd57b88a59b169c3471cbc398113d3bf98e8

URL: https://github.com/llvm/llvm-project/commit/4b35dd57b88a59b169c3471cbc398113d3bf98e8
DIFF: https://github.com/llvm/llvm-project/commit/4b35dd57b88a59b169c3471cbc398113d3bf98e8.diff

LOG: [Serialization] Try to clean up PendingUndeducedFunctionDecls when
PendingUndeducedFunctionDecls is not empty

Close https://github.com/llvm/llvm-project/issues/120277

This turns out to be a simple oversight initially. See the analysis in
https://github.com/llvm/llvm-project/commit/ba1e84fb8f45e102f40f409fcfe9b420fbf9fb70
for the wider background.

Added: 
    clang/test/Modules/pr120277.cppm

Modified: 
    clang/lib/Serialization/ASTReader.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/Serialization/ASTReader.cpp b/clang/lib/Serialization/ASTReader.cpp
index 15160b0751f83b..fccd79bf745203 100644
--- a/clang/lib/Serialization/ASTReader.cpp
+++ b/clang/lib/Serialization/ASTReader.cpp
@@ -10642,7 +10642,8 @@ void ASTReader::FinishedDeserializing() {
     // We do this now rather than in finishPendingActions because we want to
     // be able to walk the complete redeclaration chains of the updated decls.
     while (!PendingExceptionSpecUpdates.empty() ||
-           !PendingDeducedTypeUpdates.empty()) {
+           !PendingDeducedTypeUpdates.empty() ||
+           !PendingUndeducedFunctionDecls.empty()) {
       auto ESUpdates = std::move(PendingExceptionSpecUpdates);
       PendingExceptionSpecUpdates.clear();
       for (auto Update : ESUpdates) {

diff  --git a/clang/test/Modules/pr120277.cppm b/clang/test/Modules/pr120277.cppm
new file mode 100644
index 00000000000000..a4f55ef113b2cd
--- /dev/null
+++ b/clang/test/Modules/pr120277.cppm
@@ -0,0 +1,58 @@
+// RUN: rm -rf %t
+// RUN: mkdir -p %t
+// RUN: split-file %s %t
+//
+// RUN: %clang_cc1 -std=c++20 %t/a.cppm -emit-module-interface -o %t/a.pcm
+// RUN: %clang_cc1 -std=c++20 %t/b.cppm -emit-module-interface -o %t/b.pcm \
+// RUN:     -fprebuilt-module-path=%t
+// RUN: %clang_cc1 -std=c++20 %t/c.cppm -emit-module-interface -o %t/c.pcm \
+// RUN:     -fprebuilt-module-path=%t
+// RUN: %clang_cc1 -std=c++20 %t/d.cppm -emit-module-interface -o %t/d.pcm \
+// RUN:     -fprebuilt-module-path=%t
+// RUN: %clang_cc1 -std=c++20 %t/d.pcm -emit-llvm -o %t/d.ll \
+// RUN:     -fprebuilt-module-path=%t
+// RUN: cat %t/d.ll | FileCheck %t/d.cppm
+
+//--- a.cppm
+export module a;
+
+export template<int>
+struct a {
+	static auto f() {
+	}
+};
+
+//--- b.cppm
+export module b;
+
+import a;
+
+void b() {
+	a<0> t;
+}
+
+//--- c.cppm
+export module c;
+
+import a;
+
+void c() {
+	a<0>::f();
+}
+
+//--- d.cppm
+export module d;
+
+import a;
+import b;
+import c;
+
+struct d {
+	static void g() {
+		a<0>::f();
+		a<1>::f();
+	}
+};
+
+// fine enough to check it won't crash
+// CHECK: define


        


More information about the cfe-commits mailing list