Skip to content

Commit 832cd39

Browse files
committed
Addressing PR comments
1 parent 081f01f commit 832cd39

File tree

2 files changed

+34
-36
lines changed

2 files changed

+34
-36
lines changed

clang-tools-extra/clang-doc/HTMLMustacheGenerator.cpp

Lines changed: 33 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -209,14 +209,13 @@ static json::Value extractValue(const TypedefInfo &I) {
209209

210210
static json::Value extractValue(const CommentInfo &I) {
211211
Object Obj = Object();
212-
json::Value Child = Object();
212+
Object Child;
213213

214214
json::Value ChildArr = Array();
215215
auto &CARef = *ChildArr.getAsArray();
216216
CARef.reserve(I.Children.size());
217-
for (const auto &C : I.Children) {
217+
for (const auto &C : I.Children)
218218
CARef.emplace_back(extractValue(*C));
219-
}
220219

221220
switch (I.Kind) {
222221
case CommentKind::CK_TextComment: {
@@ -225,9 +224,9 @@ static json::Value extractValue(const CommentInfo &I) {
225224
}
226225

227226
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))});
231230
return Obj;
232231
}
233232

@@ -236,37 +235,37 @@ static json::Value extractValue(const CommentInfo &I) {
236235
for (const auto &Arg : I.Args) {
237236
ArgsArr.getAsArray()->emplace_back(Arg);
238237
}
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))});
243242
return Obj;
244243
}
245244

246245
case CommentKind::CK_ParamCommandComment:
247246
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))});
253252
return Obj;
254253
}
255254

256255
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});
259258
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))});
262261
return Obj;
263262
}
264263

265264
case CommentKind::CK_VerbatimBlockLineComment:
266265
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))});
270269
return Obj;
271270
}
272271

@@ -279,36 +278,35 @@ static json::Value extractValue(const CommentInfo &I) {
279278
for (const auto &Val : I.AttrValues)
280279
AttrValuesArray.getAsArray()->emplace_back(Val);
281280

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))});
288287
return Obj;
289288
}
290289

291290
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))});
295294
return Obj;
296295
}
297296

298297
case CommentKind::CK_FullComment:
299298
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))});
302301
return Obj;
303302
}
304303

305304
case CommentKind::CK_Unknown: {
306305
Obj.insert({commentKindToString(I.Kind), I.Text});
307306
return Obj;
308307
}
309-
310-
llvm_unreachable("Unknown comment kind encountered.");
311308
}
309+
llvm_unreachable("Unknown comment kind encountered.");
312310
}
313311

314312
static void maybeInsertLocation(std::optional<Location> Loc,

clang-tools-extra/clang-doc/YAMLGenerator.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ template <> struct ScalarEnumerationTraits<InfoType> {
6666
};
6767

6868
template <>
69-
struct llvm::yaml::ScalarEnumerationTraits<clang::doc::CommentKind> {
69+
struct ScalarEnumerationTraits<clang::doc::CommentKind> {
7070
static void enumeration(IO &IO, clang::doc::CommentKind &Value) {
7171
IO.enumCase(Value, "FullComment", clang::doc::CommentKind::CK_FullComment);
7272
IO.enumCase(Value, "ParagraphComment",

0 commit comments

Comments
 (0)