[clang] [extract-api] Don't crash for category in libclang APIs
Remove failure conditions for categories in libclang and return empty content instead. Differential Revision: https://reviews.llvm.org/D142101
This commit is contained in:
@@ -487,6 +487,7 @@ bool generatePathComponents(
|
||||
SmallVector<PathComponent, 4> ReverseComponenents;
|
||||
ReverseComponenents.emplace_back(Record.USR, Record.Name, Record.getKind());
|
||||
const auto *CurrentParent = &Record.ParentInformation;
|
||||
bool FailedToFindParent = false;
|
||||
while (CurrentParent && !CurrentParent->empty()) {
|
||||
PathComponent CurrentParentComponent(CurrentParent->ParentUSR,
|
||||
CurrentParent->ParentName,
|
||||
@@ -509,8 +510,10 @@ bool generatePathComponents(
|
||||
|
||||
// The parent record doesn't exist which means the symbol shouldn't be
|
||||
// treated as part of the current product.
|
||||
if (!ParentRecord)
|
||||
return true;
|
||||
if (!ParentRecord) {
|
||||
FailedToFindParent = true;
|
||||
break;
|
||||
}
|
||||
|
||||
ReverseComponenents.push_back(std::move(CurrentParentComponent));
|
||||
CurrentParent = &ParentRecord->ParentInformation;
|
||||
@@ -519,8 +522,9 @@ bool generatePathComponents(
|
||||
for (const auto &PC : reverse(ReverseComponenents))
|
||||
ComponentTransformer(PC);
|
||||
|
||||
return false;
|
||||
return FailedToFindParent;
|
||||
}
|
||||
|
||||
Object serializeParentContext(const PathComponent &PC, Language Lang) {
|
||||
Object ParentContextElem;
|
||||
ParentContextElem["usr"] = PC.USR;
|
||||
@@ -533,12 +537,15 @@ template <typename RecordTy>
|
||||
Array generateParentContexts(const RecordTy &Record, const APISet &API,
|
||||
Language Lang) {
|
||||
Array ParentContexts;
|
||||
if (generatePathComponents(
|
||||
Record, API, [Lang, &ParentContexts](const PathComponent &PC) {
|
||||
ParentContexts.push_back(serializeParentContext(PC, Lang));
|
||||
}))
|
||||
ParentContexts.clear();
|
||||
ParentContexts.pop_back();
|
||||
generatePathComponents(Record, API,
|
||||
[Lang, &ParentContexts](const PathComponent &PC) {
|
||||
ParentContexts.push_back(
|
||||
serializeParentContext(PC, Lang));
|
||||
});
|
||||
|
||||
// The last component would be the record itself so let's remove it.
|
||||
if (!ParentContexts.empty())
|
||||
ParentContexts.pop_back();
|
||||
|
||||
return ParentContexts;
|
||||
}
|
||||
@@ -865,6 +872,9 @@ SymbolGraphSerializer::serializeSingleSymbolSGF(StringRef USR,
|
||||
if (!Record)
|
||||
return {};
|
||||
|
||||
if (isa<ObjCCategoryRecord>(Record))
|
||||
return {};
|
||||
|
||||
Object Root;
|
||||
APIIgnoresList EmptyIgnores;
|
||||
SymbolGraphSerializer Serializer(API, EmptyIgnores,
|
||||
|
||||
Reference in New Issue
Block a user