aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/ExtractAPI/API.cpp
diff options
context:
space:
mode:
authorZixu Wang <zixu_wang@apple.com>2022-03-30 17:21:33 -0700
committerZixu Wang <zixu_wang@apple.com>2022-04-06 12:00:12 -0700
commit178aad9b946e3c5abe9df162e5c482fb4acae99c (patch)
tree7791542c16161e68d1b9b27d7eb9251faabdaa7f /clang/lib/ExtractAPI/API.cpp
parent6b306233f78876a1d197ed6e1f05785505de7c63 (diff)
downloadllvm-178aad9b946e3c5abe9df162e5c482fb4acae99c.zip
llvm-178aad9b946e3c5abe9df162e5c482fb4acae99c.tar.gz
llvm-178aad9b946e3c5abe9df162e5c482fb4acae99c.tar.bz2
[clang][extract-api] Add Objective-C Category support
Add (partial) support for Objective-C category records in ExtractAPI. The current ExtractAPI collects everything for an Objective-C category, but not fully serialized in the SymbolGraphSerializer. Categories extending external interfaces are disgarded during serialization, and categories extending known interfaces are merged (all members surfaced) into the interfaces. Differential Revision: https://reviews.llvm.org/D122774
Diffstat (limited to 'clang/lib/ExtractAPI/API.cpp')
-rw-r--r--clang/lib/ExtractAPI/API.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/clang/lib/ExtractAPI/API.cpp b/clang/lib/ExtractAPI/API.cpp
index 6d5ac8a..1c33bbf 100644
--- a/clang/lib/ExtractAPI/API.cpp
+++ b/clang/lib/ExtractAPI/API.cpp
@@ -109,6 +109,24 @@ StructRecord *APISet::addStruct(StringRef Name, StringRef USR, PresumedLoc Loc,
Declaration, SubHeading);
}
+ObjCCategoryRecord *APISet::addObjCCategory(
+ StringRef Name, StringRef USR, PresumedLoc Loc,
+ const AvailabilityInfo &Availability, const DocComment &Comment,
+ DeclarationFragments Declaration, DeclarationFragments SubHeading,
+ SymbolReference Interface) {
+ // Create the category record.
+ auto *Record = addTopLevelRecord(ObjCCategories, Name, USR, Loc, Availability,
+ Comment, Declaration, SubHeading, Interface);
+
+ // If this category is extending a known interface, associate it with the
+ // ObjCInterfaceRecord.
+ auto It = ObjCInterfaces.find(Interface.Name);
+ if (It != ObjCInterfaces.end())
+ It->second->Categories.push_back(Record);
+
+ return Record;
+}
+
ObjCInterfaceRecord *APISet::addObjCInterface(
StringRef Name, StringRef USR, PresumedLoc Loc,
const AvailabilityInfo &Availability, LinkageInfo Linkage,
@@ -219,6 +237,7 @@ void StructRecord::anchor() {}
void ObjCPropertyRecord::anchor() {}
void ObjCInstanceVariableRecord::anchor() {}
void ObjCMethodRecord::anchor() {}
+void ObjCCategoryRecord::anchor() {}
void ObjCInterfaceRecord::anchor() {}
void ObjCProtocolRecord::anchor() {}
void MacroDefinitionRecord::anchor() {}