================
@@ -7121,6 +7127,56 @@
TreeTransform<Derived>::TransformPackIndexingType(TypeLocBuilder &TLB,
if (Types.empty() && !PIT->expandsToEmptyPack())
Types = llvm::ArrayRef<QualType>(&Pattern, 1);
+ // Fast path: substitute only the selected element instead of all N. A
+ // pack-indexing type inside a pack expansion (`T...[Is]...`) is transformed
+ // once per outer element, so substituting the whole pack each time is
+ // O(N^2) in time and memory.
+ if (Types.size() == 1 && Types[0]->containsUnexpandedParameterPack() &&
+ IndexExpr.isUsable() && !IndexExpr.get()->isInstantiationDependent()) {
----------------
zyn0217 wrote:
Please also note that, if any AI agent is involved, you should clarify that in
your PR description: https://llvm.org/docs/AIToolPolicy.html
https://github.com/llvm/llvm-project/pull/213790
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits