@@ -132,39 +132,42 @@ void Sema::checkContainerDeclVerbatimLine(const BlockCommandComment *Comment) {
132132 const CommandInfo *Info = Traits.getCommandInfo (Comment->getCommandID ());
133133 if (!Info->IsRecordLikeDeclarationCommand )
134134 return ;
135- unsigned DiagSelect;
135+ std::optional< unsigned > DiagSelect;
136136 switch (Comment->getCommandID ()) {
137137 case CommandTraits::KCI_class:
138- DiagSelect =
139- (! isClassOrStructOrTagTypedefDecl () && ! isClassTemplateDecl ()) ? 1
140- : 0 ;
138+ if (! isClassOrStructOrTagTypedefDecl () && ! isClassTemplateDecl ())
139+ DiagSelect = diag::DeclContainerKind::Class;
140+
141141 // Allow @class command on @interface declarations.
142142 // FIXME. Currently, \class and @class are indistinguishable. So,
143143 // \class is also allowed on an @interface declaration
144144 if (DiagSelect && Comment->getCommandMarker () && isObjCInterfaceDecl ())
145- DiagSelect = 0 ;
145+ DiagSelect = std:: nullopt ;
146146 break ;
147147 case CommandTraits::KCI_interface:
148- DiagSelect = !isObjCInterfaceDecl () ? 2 : 0 ;
148+ if (!isObjCInterfaceDecl ())
149+ DiagSelect = diag::DeclContainerKind::Interface;
149150 break ;
150151 case CommandTraits::KCI_protocol:
151- DiagSelect = !isObjCProtocolDecl () ? 3 : 0 ;
152+ if (!isObjCProtocolDecl ())
153+ DiagSelect = diag::DeclContainerKind::Protocol;
152154 break ;
153155 case CommandTraits::KCI_struct:
154- DiagSelect = !isClassOrStructOrTagTypedefDecl () ? 4 : 0 ;
156+ if (!isClassOrStructOrTagTypedefDecl ())
157+ DiagSelect = diag::DeclContainerKind::Struct;
155158 break ;
156159 case CommandTraits::KCI_union:
157- DiagSelect = !isUnionDecl () ? 5 : 0 ;
160+ if (!isUnionDecl ())
161+ DiagSelect = diag::DeclContainerKind::Union;
158162 break ;
159163 default :
160- DiagSelect = 0 ;
164+ DiagSelect = std:: nullopt ;
161165 break ;
162166 }
163167 if (DiagSelect)
164168 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 ();
168171}
169172
170173void Sema::checkContainerDecl (const BlockCommandComment *Comment) {
0 commit comments