@@ -209,14 +209,13 @@ static json::Value extractValue(const TypedefInfo &I) {
209
209
210
210
static json::Value extractValue (const CommentInfo &I) {
211
211
Object Obj = Object ();
212
- json::Value Child = Object () ;
212
+ Object Child;
213
213
214
214
json::Value ChildArr = Array ();
215
215
auto &CARef = *ChildArr.getAsArray ();
216
216
CARef.reserve (I.Children .size ());
217
- for (const auto &C : I.Children ) {
217
+ for (const auto &C : I.Children )
218
218
CARef.emplace_back (extractValue (*C));
219
- }
220
219
221
220
switch (I.Kind ) {
222
221
case CommentKind::CK_TextComment: {
@@ -225,9 +224,9 @@ static json::Value extractValue(const CommentInfo &I) {
225
224
}
226
225
227
226
case CommentKind::CK_BlockCommandComment: {
228
- Child.getAsObject ()-> insert ({" Command" , I.Name });
229
- Child.getAsObject ()-> insert ({" Children" , ChildArr});
230
- Obj.insert ({commentKindToString (I.Kind ), Child});
227
+ Child.insert ({" Command" , I.Name });
228
+ Child.insert ({" Children" , ChildArr});
229
+ Obj.insert ({commentKindToString (I.Kind ), json::Value ( std::move ( Child)) });
231
230
return Obj;
232
231
}
233
232
@@ -236,37 +235,37 @@ static json::Value extractValue(const CommentInfo &I) {
236
235
for (const auto &Arg : I.Args ) {
237
236
ArgsArr.getAsArray ()->emplace_back (Arg);
238
237
}
239
- Child.getAsObject ()-> insert ({" Command" , I.Name });
240
- Child.getAsObject ()-> insert ({" Args" , ArgsArr});
241
- Child.getAsObject ()-> insert ({" Children" , ChildArr});
242
- Obj.insert ({commentKindToString (I.Kind ), Child});
238
+ Child.insert ({" Command" , I.Name });
239
+ Child.insert ({" Args" , ArgsArr});
240
+ Child.insert ({" Children" , ChildArr});
241
+ Obj.insert ({commentKindToString (I.Kind ), json::Value ( std::move ( Child)) });
243
242
return Obj;
244
243
}
245
244
246
245
case CommentKind::CK_ParamCommandComment:
247
246
case CommentKind::CK_TParamCommandComment: {
248
- Child.getAsObject ()-> insert ({" ParamName" , I.ParamName });
249
- Child.getAsObject ()-> insert ({" Direction" , I.Direction });
250
- Child.getAsObject ()-> insert ({" Explicit" , I.Explicit });
251
- Child.getAsObject ()-> insert ({" Children" , ChildArr});
252
- Obj.insert ({commentKindToString (I.Kind ), Child});
247
+ Child.insert ({" ParamName" , I.ParamName });
248
+ Child.insert ({" Direction" , I.Direction });
249
+ Child.insert ({" Explicit" , I.Explicit });
250
+ Child.insert ({" Children" , ChildArr});
251
+ Obj.insert ({commentKindToString (I.Kind ), json::Value ( std::move ( Child)) });
253
252
return Obj;
254
253
}
255
254
256
255
case CommentKind::CK_VerbatimBlockComment: {
257
- Child.getAsObject ()-> insert ({" Text" , I.Text });
258
- Child.getAsObject ()-> insert ({" Children" , ChildArr});
256
+ Child.insert ({" Text" , I.Text });
257
+ Child.insert ({" Children" , ChildArr});
259
258
if (!I.CloseName .empty ())
260
- Child.getAsObject ()-> insert ({" CloseName" , I.CloseName });
261
- Obj.insert ({commentKindToString (I.Kind ), Child});
259
+ Child.insert ({" CloseName" , I.CloseName });
260
+ Obj.insert ({commentKindToString (I.Kind ), json::Value ( std::move ( Child)) });
262
261
return Obj;
263
262
}
264
263
265
264
case CommentKind::CK_VerbatimBlockLineComment:
266
265
case CommentKind::CK_VerbatimLineComment: {
267
- Child.getAsObject ()-> insert ({" Text" , I.Text });
268
- Child.getAsObject ()-> insert ({" Children" , ChildArr});
269
- Obj.insert ({commentKindToString (I.Kind ), Child});
266
+ Child.insert ({" Text" , I.Text });
267
+ Child.insert ({" Children" , ChildArr});
268
+ Obj.insert ({commentKindToString (I.Kind ), json::Value ( std::move ( Child)) });
270
269
return Obj;
271
270
}
272
271
@@ -279,36 +278,35 @@ static json::Value extractValue(const CommentInfo &I) {
279
278
for (const auto &Val : I.AttrValues )
280
279
AttrValuesArray.getAsArray ()->emplace_back (Val);
281
280
282
- Child.getAsObject ()-> insert ({" Name" , I.Name });
283
- Child.getAsObject ()-> insert ({" SelfClosing" , I.SelfClosing });
284
- Child.getAsObject ()-> insert ({" AttrKeys" , AttrKeysArray});
285
- Child.getAsObject ()-> insert ({" AttrValues" , AttrValuesArray});
286
- Child.getAsObject ()-> insert ({" Children" , ChildArr});
287
- Obj.insert ({commentKindToString (I.Kind ), Child});
281
+ Child.insert ({" Name" , I.Name });
282
+ Child.insert ({" SelfClosing" , I.SelfClosing });
283
+ Child.insert ({" AttrKeys" , AttrKeysArray});
284
+ Child.insert ({" AttrValues" , AttrValuesArray});
285
+ Child.insert ({" Children" , ChildArr});
286
+ Obj.insert ({commentKindToString (I.Kind ), json::Value ( std::move ( Child)) });
288
287
return Obj;
289
288
}
290
289
291
290
case CommentKind::CK_HTMLEndTagComment: {
292
- Child.getAsObject ()-> insert ({" Name" , I.Name });
293
- Child.getAsObject ()-> insert ({" Children" , ChildArr});
294
- Obj.insert ({commentKindToString (I.Kind ), Child});
291
+ Child.insert ({" Name" , I.Name });
292
+ Child.insert ({" Children" , ChildArr});
293
+ Obj.insert ({commentKindToString (I.Kind ), json::Value ( std::move ( Child)) });
295
294
return Obj;
296
295
}
297
296
298
297
case CommentKind::CK_FullComment:
299
298
case CommentKind::CK_ParagraphComment: {
300
- Child.getAsObject ()-> insert ({" Children" , ChildArr});
301
- Obj.insert ({commentKindToString (I.Kind ), Child});
299
+ Child.insert ({" Children" , ChildArr});
300
+ Obj.insert ({commentKindToString (I.Kind ), json::Value ( std::move ( Child)) });
302
301
return Obj;
303
302
}
304
303
305
304
case CommentKind::CK_Unknown: {
306
305
Obj.insert ({commentKindToString (I.Kind ), I.Text });
307
306
return Obj;
308
307
}
309
-
310
- llvm_unreachable (" Unknown comment kind encountered." );
311
308
}
309
+ llvm_unreachable (" Unknown comment kind encountered." );
312
310
}
313
311
314
312
static void maybeInsertLocation (std::optional<Location> Loc,
0 commit comments