[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
================
@@ -1669,25 +1640,43 @@ namespace {
ExprResult RebuildLambdaExpr(SourceLocation StartLoc, SourceLocation EndLoc,
LambdaScopeInfo *LSI) {
+#if 1
CXXMethodDecl *MD = LSI->CallOperator;
- for (ParmVarDecl *PVD : MD->parameters()) {
- assert(PVD && "null in a parameter list");
- if (!PVD->hasDefaultArg())
- continue;
- Expr *UninstExpr = PVD->getUninstantiatedDefaultArg();
- // FIXME: Obtain the source location for the '=' token.
- SourceLocation EqualLoc = UninstExpr->getBeginLoc();
- if (SemaRef.SubstDefaultArgument(EqualLoc, PVD, TemplateArgs)) {
- // If substitution fails, the default argument is set to a
- // RecoveryExpr that wraps the uninstantiated default argument so
- // that downstream diagnostics are omitted.
- ExprResult ErrorResult = SemaRef.CreateRecoveryExpr(
- UninstExpr->getBeginLoc(), UninstExpr->getEndLoc(),
- { UninstExpr }, UninstExpr->getType());
- if (ErrorResult.isUsable())
- PVD->setDefaultArg(ErrorResult.get());
+ // if (MD->getParentFunctionOrMethod()) {
+ if (true) {
+#if 0
+ NamedDecl *Pattern = MD;
+ std::optional<ArrayRef<TemplateArgument>> Innermost;
+ if (FunctionTemplateDecl *FTD = MD->getDescribedFunctionTemplate()) {
+ Pattern = FTD;
+ Innermost = FTD->getInjectedTemplateArgs();
+ }
+ MultiLevelTemplateArgumentList MLTAL =
+ SemaRef.getTemplateInstantiationArgs(Pattern, Pattern->getLexicalDeclContext(),
+ /*Final=*/false, Innermost,
+ /*RelativeToPrimary=*/true);
+#endif
+ ;
----------------
zyn0217 wrote:
Does that still affect anything? Given that we have a similar pattern in `InstantiateDefaultArgument`, should we move the logic there?
https://github.com/llvm/llvm-project/pull/106585
More information about the cfe-commits
mailing list