================
@@ -1611,15 +1618,32 @@ namespace {
}
return Type;
}
+
// Override the default version to handle a rewrite-template-arg-pack case
- // for building a deduction guide.
+ // for building a deduction guide, and to cache substitution results in
+ // concepts checking.
bool TransformTemplateArgument(const TemplateArgumentLoc &Input,
TemplateArgumentLoc &Output,
bool Uneval = false) {
const TemplateArgument &Arg = Input.getArgument();
- std::vector<TemplateArgument> TArgs;
+ if (auto *Cache = SemaRef.CurrentCachedTemplateArgs;
+ Cache && TemplateArgsHashValue) {
+ llvm::FoldingSetNodeID ID = *TemplateArgsHashValue;
+ ID.AddInteger(SemaRef.ArgPackSubstIndex.toInternalRepresentation());
+ // FIXME: We can lose sugars when profiling Arg.
+ Arg.Profile(ID, SemaRef.Context);
+ if (auto Iter = Cache->find(ID); Iter != Cache->end()) {
+ Output = Iter->second;
----------------
mizvekov wrote:
I think it's worth adding the FIXME here mirroring the note about source
location fidelity.
Something to the effect:
We should be caching and restoring only the TemplateArgument, but always
building a TemplateArgumentLoc with the original uncached locations in place.
Otherwise this might result in diagnostics pointing to arbitrary locations.
https://github.com/llvm/llvm-project/pull/188421
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits