Skip to content

Commit b300c6c

Browse files
committed
replace select with enum_select
1 parent 2bf3cca commit b300c6c

File tree

2 files changed

+14
-11
lines changed

2 files changed

+14
-11
lines changed

clang/include/clang/Basic/DiagnosticCommentKinds.td

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,9 @@ def warn_doc_param_not_attached_to_a_function_decl : Warning<
7777
InGroup<Documentation>, DefaultIgnore;
7878

7979
def warn_doc_function_method_decl_mismatch : Warning<
80-
"'%select{\\|@}0%select{function|functiongroup|method|methodgroup|callback}1' "
80+
"'%select{\\|@}0%enum_select<CallableKind>{"
81+
"%Function{function}|%FunctionGroup{functiongroup}|"
82+
"%Method{method}|%MethodGroup{methodgroup}|%Callback{callback}}1' "
8183
"command should be used in a comment attached to "
8284
"%select{a function|a function|an Objective-C method|an Objective-C method|"
8385
"a pointer to function}2 declaration">,

clang/lib/AST/CommentSema.cpp

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -100,32 +100,33 @@ void Sema::checkFunctionDeclVerbatimLine(const BlockCommandComment *Comment) {
100100
if (!Info->IsFunctionDeclarationCommand)
101101
return;
102102

103-
unsigned DiagSelect;
103+
std::optional<unsigned> DiagSelect;
104104
switch (Comment->getCommandID()) {
105105
case CommandTraits::KCI_function:
106-
DiagSelect = (!isAnyFunctionDecl() && !isFunctionTemplateDecl())? 1 : 0;
106+
if (!isAnyFunctionDecl() && !isFunctionTemplateDecl())
107+
DiagSelect = diag::CallableKind::Function;
107108
break;
108109
case CommandTraits::KCI_functiongroup:
109-
DiagSelect = (!isAnyFunctionDecl() && !isFunctionTemplateDecl())? 2 : 0;
110+
if (!isAnyFunctionDecl() && !isFunctionTemplateDecl())
111+
DiagSelect = diag::CallableKind::FunctionGroup;
110112
break;
111113
case CommandTraits::KCI_method:
112-
DiagSelect = !isObjCMethodDecl() ? 3 : 0;
114+
DiagSelect = diag::CallableKind::Method;
113115
break;
114116
case CommandTraits::KCI_methodgroup:
115-
DiagSelect = !isObjCMethodDecl() ? 4 : 0;
117+
DiagSelect = diag::CallableKind::MethodGroup;
116118
break;
117119
case CommandTraits::KCI_callback:
118-
DiagSelect = !isFunctionPointerVarDecl() ? 5 : 0;
120+
DiagSelect = diag::CallableKind::Callback;
119121
break;
120122
default:
121-
DiagSelect = 0;
123+
DiagSelect = std::nullopt;
122124
break;
123125
}
124126
if (DiagSelect)
125127
Diag(Comment->getLocation(), diag::warn_doc_function_method_decl_mismatch)
126-
<< Comment->getCommandMarker()
127-
<< (DiagSelect-1) << (DiagSelect-1)
128-
<< Comment->getSourceRange();
128+
<< Comment->getCommandMarker() << (*DiagSelect) << (*DiagSelect)
129+
<< Comment->getSourceRange();
129130
}
130131

131132
void Sema::checkContainerDeclVerbatimLine(const BlockCommandComment *Comment) {

0 commit comments

Comments
 (0)