@@ -178,12 +178,13 @@ template <> struct MappingTraits<ClangTidyOptions::CustomCheckValue> {
178178 }
179179};
180180
181- struct ChecksVariant {
181+ struct GlobListVariant {
182182 std::optional<std::string> AsString;
183183 std::optional<std::vector<std::string>> AsVector;
184184};
185185
186- template <> void yamlize (IO &IO, ChecksVariant &Val, bool , EmptyContext &Ctx) {
186+ template <>
187+ void yamlize (IO &IO, GlobListVariant &Val, bool , EmptyContext &Ctx) {
187188 if (!IO.outputting ()) {
188189 // Special case for reading from YAML
189190 // Must support reading from both a string or a list
@@ -200,25 +201,26 @@ template <> void yamlize(IO &IO, ChecksVariant &Val, bool, EmptyContext &Ctx) {
200201 }
201202}
202203
203- static void mapChecks (IO &IO, std::optional<std::string> &Checks) {
204+ static void mapGlobList (IO &IO, std::optional<std::string> &GlobList,
205+ StringRef Key) {
204206 if (IO.outputting ()) {
205207 // Output always a string
206- IO.mapOptional (" Checks " , Checks );
208+ IO.mapOptional (Key, GlobList );
207209 } else {
208210 // Input as either a string or a list
209- ChecksVariant ChecksAsVariant ;
210- IO.mapOptional (" Checks " , ChecksAsVariant );
211- if (ChecksAsVariant .AsString )
212- Checks = ChecksAsVariant .AsString ;
213- else if (ChecksAsVariant .AsVector )
214- Checks = llvm::join (*ChecksAsVariant .AsVector , " ," );
211+ GlobListVariant GlobListAsVariant ;
212+ IO.mapOptional (Key, GlobListAsVariant );
213+ if (GlobListAsVariant .AsString )
214+ GlobList = GlobListAsVariant .AsString ;
215+ else if (GlobListAsVariant .AsVector )
216+ GlobList = llvm::join (*GlobListAsVariant .AsVector , " ," );
215217 }
216218}
217219
218220template <> struct MappingTraits <ClangTidyOptions> {
219221 static void mapping (IO &IO, ClangTidyOptions &Options) {
220- mapChecks (IO, Options.Checks );
221- IO. mapOptional ( " WarningsAsErrors " , Options.WarningsAsErrors );
222+ mapGlobList (IO, Options.Checks , " Checks " );
223+ mapGlobList (IO , Options.WarningsAsErrors , " WarningsAsErrors " );
222224 IO.mapOptional (" HeaderFileExtensions" , Options.HeaderFileExtensions );
223225 IO.mapOptional (" ImplementationFileExtensions" ,
224226 Options.ImplementationFileExtensions );
0 commit comments