@@ -132,39 +132,42 @@ void Sema::checkContainerDeclVerbatimLine(const BlockCommandComment *Comment) {
132
132
const CommandInfo *Info = Traits.getCommandInfo (Comment->getCommandID ());
133
133
if (!Info->IsRecordLikeDeclarationCommand )
134
134
return ;
135
- unsigned DiagSelect;
135
+ std::optional< unsigned > DiagSelect;
136
136
switch (Comment->getCommandID ()) {
137
137
case CommandTraits::KCI_class:
138
- DiagSelect =
139
- (! isClassOrStructOrTagTypedefDecl () && ! isClassTemplateDecl ()) ? 1
140
- : 0 ;
138
+ if (! isClassOrStructOrTagTypedefDecl () && ! isClassTemplateDecl ())
139
+ DiagSelect = diag::DeclContainerKind::Class;
140
+
141
141
// Allow @class command on @interface declarations.
142
142
// FIXME. Currently, \class and @class are indistinguishable. So,
143
143
// \class is also allowed on an @interface declaration
144
144
if (DiagSelect && Comment->getCommandMarker () && isObjCInterfaceDecl ())
145
- DiagSelect = 0 ;
145
+ DiagSelect = std::nullopt ;
146
146
break ;
147
147
case CommandTraits::KCI_interface:
148
- DiagSelect = !isObjCInterfaceDecl () ? 2 : 0 ;
148
+ if (!isObjCInterfaceDecl ())
149
+ DiagSelect = diag::DeclContainerKind::Interface;
149
150
break ;
150
151
case CommandTraits::KCI_protocol:
151
- DiagSelect = !isObjCProtocolDecl () ? 3 : 0 ;
152
+ if (!isObjCProtocolDecl ())
153
+ DiagSelect = diag::DeclContainerKind::Protocol;
152
154
break ;
153
155
case CommandTraits::KCI_struct:
154
- DiagSelect = !isClassOrStructOrTagTypedefDecl () ? 4 : 0 ;
156
+ if (!isClassOrStructOrTagTypedefDecl ())
157
+ DiagSelect = diag::DeclContainerKind::Struct;
155
158
break ;
156
159
case CommandTraits::KCI_union:
157
- DiagSelect = !isUnionDecl () ? 5 : 0 ;
160
+ if (!isUnionDecl ())
161
+ DiagSelect = diag::DeclContainerKind::Union;
158
162
break ;
159
163
default :
160
- DiagSelect = 0 ;
164
+ DiagSelect = std::nullopt ;
161
165
break ;
162
166
}
163
167
if (DiagSelect)
164
168
Diag (Comment->getLocation (), diag::warn_doc_api_container_decl_mismatch)
165
- << Comment->getCommandMarker ()
166
- << (DiagSelect-1 ) << (DiagSelect-1 )
167
- << Comment->getSourceRange ();
169
+ << Comment->getCommandMarker () << (*DiagSelect) << (*DiagSelect)
170
+ << Comment->getSourceRange ();
168
171
}
169
172
170
173
void Sema::checkContainerDecl (const BlockCommandComment *Comment) {
0 commit comments