[clang] [clang][diagnostics] Refactor `warn_doc_function_method_decl_mismatch` to use enum_select (PR #181769)
Erich Keane via cfe-commits
cfe-commits at lists.llvm.org
Tue Feb 17 06:26:31 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:
IF we're completely covering the CommandTraits type, we should skip the 'default' here.
https://github.com/llvm/llvm-project/pull/181769
More information about the cfe-commits
mailing list