[clang] [Clang][Sema] Refactor collection of multi-level template argument lists (PR #106585)
Younan Zhang via cfe-commits
cfe-commits at lists.llvm.org
Thu Aug 29 18:59:06 PDT 2024
================
@@ -4682,6 +4683,17 @@ bool Sema::InstantiateDefaultArgument(SourceLocation CallLoc, FunctionDecl *FD,
ParmVarDecl *Param) {
assert(Param->hasUninstantiatedDefaultArg());
+ NamedDecl *Pattern = FD;
+ std::optional<ArrayRef<TemplateArgument>> Innermost;
+
+ if (FD->isCXXClassMember() &&
+ !isGenericLambdaCallOperatorOrStaticInvokerSpecialization(FD)) {
+ if (FunctionTemplateDecl *FTD = FD->getPrimaryTemplate()) {
+ Pattern = FTD->getFirstDecl();
+ Innermost = FD->getTemplateSpecializationArgs()->asArray();
+ }
+ }
+
----------------
zyn0217 wrote:
Yeah, this is why default arguments are special: the default arguments are copied from its first declaration and thus could reference outer template parameters outside of the specialization. Can you add some comments around it?
(I added the `ForDefaultArgumentSubstitution` flag because I somehow don't like special-casing something that is possibly handled by `getTemplateInstantiationArgs`, though that would add one more state to that function. So this is a trade-off.)
https://github.com/llvm/llvm-project/pull/106585
More information about the cfe-commits
mailing list