[clang] [C++20] [Modules] Profiling non dependent noexcept expression by pointer (PR #224528)
Chuanqi Xu via cfe-commits
cfe-commits at lists.llvm.org
Fri Sep 18 00:07:47 PDT 2026
================
@@ -0,0 +1,37 @@
+// RUN: mkdir -p %t
+// RUN: split-file %s %t
+//
+// RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/a.cppm -o %t/a.pcm
+// RUN: %clang_cc1 -std=c++20 -fmodule-file=a=%t/a.pcm -fsyntax-only %t/use.cpp -verify
+//
+// RUN: %clang_cc1 -std=c++20 -emit-reduced-module-interface %t/a.cppm -o %t/a.pcm
+// RUN: %clang_cc1 -std=c++20 -fmodule-file=a=%t/a.pcm -fsyntax-only %t/use.cpp -verify
+
+//--- a.cppm
+export module a;
+template <class> concept C = true;
+
+template <class T> int fn() noexcept(C<T>);
+export using t = decltype(fn<int>());
+
+//--- use.cpp
+// expected-no-diagnostics
+import a;
+
+// During the deserialization process of fn<int>, the C<int> in noexcept expression
+// may be not completely deserialized. This test makes sure that we can handle the case.
+//
+// The ordering is:
+//
+// Deserialize C<int>
+//
+// Deserializing C<int>'s template argument
+//
+// Read SubstTemplateTypeParmType::AssociatedDecl in readSubstTemplateTypeParmType
----------------
ChuanqiXu9 wrote:
I am not sure. I am not familiar with the logic in that part. And you can take a look at `Class = SubstTemplateTypeParmType` in clang/include/clang/AST/TypeProperties.td, which defines that if we read a SubstTemplateTypeParmType, we need to read the associated decl. This is the direct cause of the problem. It is true if you can avoid setting the associated decl in SubstTemplateTypeParmType, we can avoid the problem too. But I don't know if it is logically correct.
But after all, I think the current patch is correct as we can argue it is a pure optimization.
https://github.com/llvm/llvm-project/pull/224528
More information about the cfe-commits
mailing list