[clang] [clang][Sema][NFC] Clean up `diagnoseMissingArgument` (PR #231072)
via cfe-commits
cfe-commits at lists.llvm.org
Sun Oct 11 22:57:57 PDT 2026
llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang
Author: Yanzuo Liu (zwuis)
<details>
<summary>Changes</summary>
- Remove unused function parameter
- Change the return type to `void` since it always returned `true`
---
Full diff: https://github.com/llvm/llvm-project/pull/231072.diff
1 Files Affected:
- (modified) clang/lib/Sema/SemaTemplate.cpp (+11-16)
``````````diff
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;
}
``````````
</details>
https://github.com/llvm/llvm-project/pull/231072
More information about the cfe-commits
mailing list