[PATCH] D37341: [Sema] Fix an assert-on-invalid by avoiding function template specialisation deduction for invalid functions with fabricated template arguments
Alex Lorenz via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Oct 23 16:30:08 PDT 2017
arphaman marked an inline comment as done.
arphaman added a comment.
In https://reviews.llvm.org/D37341#869042, @vsapsai wrote:
> Does your fix work for deeper nesting too (e.g. template in template in template)? Looks like it should, just want to confirm.
Yes.
> Are there other places where you need to avoid calling `DeduceTemplateArguments` due to templates depth mismatch? `CheckDependentFunctionTemplateSpecialization` should be OK as it's not deducing template arguments. But I'm not sure about `CheckMemberSpecialization`. It doesn't call `DeduceTemplateArguments` directly but I haven't dug deep enough to confirm it's not performing deduction indirectly.
The problem only seems to happen when the TPL is fabricated. I didn't see other potential places where such an issue might happen.
================
Comment at: lib/Sema/SemaDecl.cpp:8880-8881
<< NewFD->getDeclName();
- } else if (CheckFunctionTemplateSpecialization(NewFD,
+ } else if (!HasFabricatedTemplateSpecializationTemplateParams &&
+ CheckFunctionTemplateSpecialization(NewFD,
(HasExplicitTemplateArgs ? &TemplateArgs
----------------
vsapsai wrote:
> Will something more general like
>
> !NewFD->isInvalidDecl() && CheckFunctionTemplateSpecialization(...)
>
> work here? Because if matching template parameters to scope specifier fails, `NewFD` is marked as invalid decl and seems like we can use that.
Yeah, good idea.
Repository:
rL LLVM
https://reviews.llvm.org/D37341
More information about the cfe-commits
mailing list