================ @@ -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:
> I'm wondering if we could avoid substituting into default arguments if we > already know the friend declaration is not a definition. @zyn0217 I’ve thought about omitting the substitution for default arguments in https://github.com/llvm/llvm-project/blob/e577f14b670ee2ae6bb717133310b215be4331b3/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp#L4688 or https://github.com/llvm/llvm-project/blob/10a1ea9b53647c1511d3cce8fa7637f8ffdb39b5/clang/lib/Sema/SemaExpr.cpp#L5515-L5518 However, I’m not certain that it’s safe to skip https://github.com/llvm/llvm-project/blob/10a1ea9b53647c1511d3cce8fa7637f8ffdb39b5/clang/lib/Sema/SemaTemplateInstantiate.cpp#L3446-L3449 While I was investigating it, I tried to skip it early., however, for example, the following test encountered an assertion failure https://github.com/llvm/llvm-project/blob/10a1ea9b53647c1511d3cce8fa7637f8ffdb39b5/clang/test/CodeGenCXX/mangle-lambdas.cpp#L243-L256 https://github.com/llvm/llvm-project/pull/113777 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits