[clang] [clang][Sema][NFC] Clean up `diagnoseMissingArgument` (PR #231072)
Yanzuo Liu via cfe-commits
cfe-commits at lists.llvm.org
Sun Oct 11 22:57:22 PDT 2026
https://github.com/zwuis created https://github.com/llvm/llvm-project/pull/231072
- Remove unused function parameter
- Change the return type to `void` since it always returned `true`
>From 4c9f1c0cee4708a17ccc7e5b8d1a7f927d57ead7 Mon Sep 17 00:00:00 2001
From: Yanzuo Liu <zwuis at outlook.com>
Date: Mon, 12 Oct 2026 13:45:22 +0800
Subject: [PATCH] Clean up `diagnoseMissingArgument`
---
clang/lib/Sema/SemaTemplate.cpp | 27 +++++++++++----------------
1 file changed, 11 insertions(+), 16 deletions(-)
diff --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp
index 4406e81d189b6..bc3481133ca1f 100644
--- a/clang/lib/Sema/SemaTemplate.cpp
+++ b/clang/lib/Sema/SemaTemplate.cpp
@@ -5851,11 +5851,10 @@ bool Sema::CheckTemplateArgument(NamedDecl *Param, TemplateArgumentLoc &ArgLoc,
}
/// Diagnose a missing template argument.
-template<typename TemplateParmDecl>
-static bool diagnoseMissingArgument(Sema &S, SourceLocation Loc,
+template <typename TemplateParmDecl>
+static void diagnoseMissingArgument(Sema &S, SourceLocation Loc,
TemplateDecl *TD,
- const TemplateParmDecl *D,
- TemplateArgumentListInfo &Args) {
+ const TemplateParmDecl *D) {
// Dig out the most recent declaration of the template parameter; there may be
// declarations of the template that are more recent than TD.
D = cast<TemplateParmDecl>(cast<TemplateDecl>(TD->getMostRecentDecl())
@@ -5870,7 +5869,7 @@ static bool diagnoseMissingArgument(Sema &S, SourceLocation Loc,
D->getDefaultArgumentLoc(), Modules,
Sema::MissingImportKind::DefaultArgument,
/*Recover*/true);
- return true;
+ return;
}
// FIXME: If there's a more recent default argument that *is* visible,
@@ -5883,7 +5882,6 @@ static bool diagnoseMissingArgument(Sema &S, SourceLocation Loc,
<< (int)S.getTemplateNameKindForDiagnostics(TemplateName(TD))
<< TD;
S.NoteTemplateLocation(*TD, Params->getSourceRange());
- return true;
}
/// Check that the given template argument list is well-formed
@@ -6159,16 +6157,13 @@ bool Sema::CheckTemplateArgumentList(
if (Arg.getArgument().isNull()) {
if (!HasDefaultArg) {
- if (TemplateTypeParmDecl *TTP = dyn_cast<TemplateTypeParmDecl>(*Param))
- return diagnoseMissingArgument(*this, TemplateLoc, Template, TTP,
- NewArgs);
- if (NonTypeTemplateParmDecl *NTTP =
- dyn_cast<NonTypeTemplateParmDecl>(*Param))
- return diagnoseMissingArgument(*this, TemplateLoc, Template, NTTP,
- NewArgs);
- return diagnoseMissingArgument(*this, TemplateLoc, Template,
- cast<TemplateTemplateParmDecl>(*Param),
- NewArgs);
+ if (auto *TTP = dyn_cast<TemplateTypeParmDecl>(*Param))
+ diagnoseMissingArgument(*this, TemplateLoc, Template, TTP);
+ else if (auto *NTTP = dyn_cast<NonTypeTemplateParmDecl>(*Param))
+ diagnoseMissingArgument(*this, TemplateLoc, Template, NTTP);
+ else
+ diagnoseMissingArgument(*this, TemplateLoc, Template,
+ cast<TemplateTemplateParmDecl>(*Param));
}
return true;
}
More information about the cfe-commits
mailing list