[clang] [clang] Share normalized constraints between decls with same constraint expressions (PR #226620)

Nico Weber via cfe-commits cfe-commits at lists.llvm.org
Mon Sep 28 11:55:27 PDT 2026


================
@@ -15186,6 +15186,11 @@ class Sema final : public SemaBase {
   /// here.
   llvm::DenseMap<ConstrainedDeclOrNestedRequirement, NormalizedConstraint *>
       NormalizationCache;
+  /// Caches the normal form of constraint expressions (and their pack
+  /// substitution index). These are shared by e.g. the members of all
+  /// specializations of a class template. Used to fill NormalizationCache.
+  llvm::DenseMap<std::pair<const Expr *, unsigned>, NormalizedConstraint *>
+      NormalizedConstraintExprCache;
----------------
nico wrote:

Oh, that's a great suggestion! It seems to work, is less code, and has the same perf. It does change error-case diagnostics some. But it looks like that might be a progression. I put the error diag change into #227086 so that this PR here can stay behavior-preserving. I'll update this PR here once #227086 is done :)

https://github.com/llvm/llvm-project/pull/226620


More information about the cfe-commits mailing list