[clang] [C++20] [Modules] Profiling non dependent noexcept expression by pointer (PR #224528)
Younan Zhang via cfe-commits
cfe-commits at lists.llvm.org
Fri Sep 18 02:24:17 PDT 2026
================
@@ -4094,7 +4094,19 @@ void FunctionProtoType::Profile(llvm::FoldingSetNodeID &ID, QualType Result,
if (epi.ExceptionSpec.Type == EST_Dynamic) {
for (QualType Ex : epi.ExceptionSpec.Exceptions)
ID.AddPointer(Ex.getAsOpaquePtr());
- } else if (isComputedNoexcept(epi.ExceptionSpec.Type)) {
+ } else if (epi.ExceptionSpec.Type == EST_NoexceptTrue ||
+ epi.ExceptionSpec.Type == EST_NoexceptFalse) {
+ // If the exception type has already been determined, we can use the
+ // address of the expression as profiling results instead of profiling the
+ // expression.
+ //
+ // This is not only an optimization but avoids an access on uninitialized
+ // fields during the profiling.
+ //
+ // See clang/test/Modules/concept-specialization-deserialization.cppm for
+ // an example.
+ ID.AddPointer(epi.ExceptionSpec.NoexceptExpr);
----------------
zyn0217 wrote:
```suggestion
// Template arguments of concept specializations can share associated declarations with those of a noexcept specifier, which can lead to uninitialized memory access when profiling a FunctionTypeLoc.
//
// See clang/test/Modules/concept-specialization-deserialization.cppm for
// an example.
ID.AddPointer(epi.ExceptionSpec.NoexceptExpr);
```
https://github.com/llvm/llvm-project/pull/224528
More information about the cfe-commits
mailing list