================
@@ -98,10 +114,29 @@ static void insertComment(Object &Description, json::Value
&Comment,
}
}
+/// Takes the nested "Children" array from a comment Object.
+///
+/// \return a json::Array of comments, possible json::Value::Kind::Null
static json::Value extractTextComments(Object *ParagraphComment) {
if (!ParagraphComment)
- return json::Object();
- return *ParagraphComment->get("Children");
+ return json::Value(nullptr);
+ json::Value *Children = ParagraphComment->get("Children");
+ if (!Children)
+ return json::Value(nullptr);
+ auto ChildrenArray = *Children->getAsArray();
+ auto ChildrenIt = ChildrenArray.begin();
+ while (ChildrenIt != ChildrenArray.end()) {
+ auto *ChildObj = ChildrenIt->getAsObject();
+ if (!ChildObj)
+ break;
----------------
ilovepi wrote:
What I was asking before was why we bail out i its not an object. Your comment
makes me think we're in an error state. If that's the case, just us an assert,
otherwise, I guess we may need to return an error. I'd like to avoid adding
complex error handling all over the place though. I'm fine either way, I just
want to understand why we think its good to bail or not.
Probably an assert is plenty to communicate that if the pointer is NULL, then
we're in an invalid state.
https://github.com/llvm/llvm-project/pull/169087
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits