[clang] 0c120c9 - [clang][Sema][NFC] Clean up `diagnoseMissingArgument` (#231072)
via cfe-commits
cfe-commits at lists.llvm.org
Mon Oct 12 23:35:08 PDT 2026
Author: Yanzuo Liu
Date: 2026-10-13T14:35:03+08:00
New Revision: 0c120c98713d0da4e88a93ad523b52a149223827
URL: https://github.com/llvm/llvm-project/commit/0c120c98713d0da4e88a93ad523b52a149223827
DIFF: https://github.com/llvm/llvm-project/commit/0c120c98713d0da4e88a93ad523b52a149223827.diff
LOG: [clang][Sema][NFC] Clean up `diagnoseMissingArgument` (#231072)
- Remove unused function parameter
- Change the return type to `void` since it always returned `true`
Added:
Modified:
clang/lib/Sema/SemaTemplate.cpp
Removed:
################################################################################
diff --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp
index 499563dd3c155..42b715fe3f6c2 100644
--- a/clang/lib/Sema/SemaTemplate.cpp
+++ b/clang/lib/Sema/SemaTemplate.cpp
@@ -5861,11 +5861,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())
@@ -5880,7 +5879,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,
@@ -5893,7 +5892,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
@@ -6169,16 +6167,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