[clang] [clang][diagnostics] Refactor "warn_doc_function_method_decl_mismatch" to use enum_select (PR #146426)
Erich Keane via cfe-commits
cfe-commits at lists.llvm.org
Sat Feb 14 18:31:28 PST 2026
================
@@ -100,32 +100,33 @@ void Sema::checkFunctionDeclVerbatimLine(const BlockCommandComment *Comment) {
if (!Info->IsFunctionDeclarationCommand)
return;
- unsigned DiagSelect;
+ std::optional<unsigned> DiagSelect;
switch (Comment->getCommandID()) {
case CommandTraits::KCI_function:
- DiagSelect = (!isAnyFunctionDecl() && !isFunctionTemplateDecl())? 1 : 0;
+ if (!isAnyFunctionDecl() && !isFunctionTemplateDecl())
+ DiagSelect = diag::CallableKind::Function;
break;
case CommandTraits::KCI_functiongroup:
- DiagSelect = (!isAnyFunctionDecl() && !isFunctionTemplateDecl())? 2 : 0;
+ if (!isAnyFunctionDecl() && !isFunctionTemplateDecl())
+ DiagSelect = diag::CallableKind::FunctionGroup;
break;
case CommandTraits::KCI_method:
- DiagSelect = !isObjCMethodDecl() ? 3 : 0;
+ DiagSelect = diag::CallableKind::Method;
break;
case CommandTraits::KCI_methodgroup:
- DiagSelect = !isObjCMethodDecl() ? 4 : 0;
+ DiagSelect = diag::CallableKind::MethodGroup;
break;
case CommandTraits::KCI_callback:
- DiagSelect = !isFunctionPointerVarDecl() ? 5 : 0;
+ DiagSelect = diag::CallableKind::Callback;
break;
default:
- DiagSelect = 0;
+ DiagSelect = std::nullopt;
----------------
erichkeane wrote:
I'd rather just omit the 'default' here. Default ctor should handle the nullopt construction.
https://github.com/llvm/llvm-project/pull/146426
More information about the cfe-commits
mailing list