[clang] [Clang] prevent assertion failure from an invalid template instantiation pattern when adding instantiated params to the scope in friend functions with defaulted params (PR #113777)
Oleksandr T. via cfe-commits
cfe-commits at lists.llvm.org
Fri Nov 1 01:43:36 PDT 2024
================
@@ -3437,10 +3437,10 @@ bool Sema::SubstDefaultArgument(
// template<typename T> void f(T a, int = decltype(a)());
// void g() { f(0); }
LIS = std::make_unique<LocalInstantiationScope>(*this);
- FunctionDecl *PatternFD = FD->getTemplateInstantiationPattern(
- /*ForDefinition*/ false);
- if (addInstantiatedParametersToScope(FD, PatternFD, *LIS, TemplateArgs))
- return true;
+ if (FunctionDecl *PatternFD =
+ FD->getTemplateInstantiationPattern(/*ForDefinition*/ false))
+ if (addInstantiatedParametersToScope(FD, PatternFD, *LIS, TemplateArgs))
+ return true;
----------------
a-tarasyuk wrote:
@zyn0217 thanks for the feedback.
> How about lifting the check for PatternFD to ForCallExpr?
A check for `ForCallExpr` is already present above
https://github.com/llvm/llvm-project/blob/1e19f0f9d92b5e9c43d53893e387341835d3d96b/clang/lib/Sema/SemaTemplateInstantiate.cpp#L3433
https://github.com/llvm/llvm-project/pull/113777
More information about the cfe-commits
mailing list