[clang] [Clang] Improve concept performance 1/N (PR #188421)

Younan Zhang via cfe-commits cfe-commits at lists.llvm.org
Mon Mar 30 20:47:39 PDT 2026


================
@@ -1611,13 +1618,28 @@ namespace {
       }
       return Type;
     }
+
     // Override the default version to handle a rewrite-template-arg-pack case
     // for building a deduction guide.
     bool TransformTemplateArgument(const TemplateArgumentLoc &Input,
                                    TemplateArgumentLoc &Output,
                                    bool Uneval = false) {
       const TemplateArgument &Arg = Input.getArgument();
       std::vector<TemplateArgument> TArgs;
+      if (auto *Cache = SemaRef.CurrentCachedTemplateArgs;
+          TemplateArgsHashValue && Cache) {
+        llvm::FoldingSetNodeID ID = *TemplateArgsHashValue;
+        ID.AddInteger(SemaRef.ArgPackSubstIndex.toInternalRepresentation());
+        Input.getArgument().Profile(ID, SemaRef.Context);
----------------
zyn0217 wrote:

Thinking twice, I realized that this cache would inevitably break TypeLoc fidelity of normalized template arguments.

So we limit the cache to only concept substitutions and valid transforms, where the transformed TypeLoc may not necessarily make a difference.

Any suggestion is welcome, to fix the problem that the normalization duplicated template parameters and entailed too many transforms.


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


More information about the cfe-commits mailing list