diff options
Diffstat (limited to 'clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp')
-rw-r--r-- | clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp | 28 |
1 files changed, 19 insertions, 9 deletions
diff --git a/clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp b/clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp index 01e9b37..8beb016 100644 --- a/clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp +++ b/clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp @@ -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, |