[PATCH] D152770: [clang][ExtractAPI] Add support for Objective-C categories

Daniel Grumberg via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Aug 2 08:58:17 PDT 2023


dang added inline comments.


================
Comment at: clang/include/clang/ExtractAPI/ExtractAPIVisitor.h:488
+  bool IsFromExternalModule = true;
+  for (const auto &Interface : API.getObjCInterfaces()) {
+    if (InterfaceDecl->getName() == Interface.second.get()->Name) {
----------------
I think this is fine for now but there must be a better way of doing this that doesn't involve traversing the whole APISet


================
Comment at: clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp:219
   Object Identifier;
-  Identifier["precise"] = Record.USR;
+  if (auto *CategoryRecord =
+          dyn_cast_or_null<const ObjCCategoryRecord>(&Record))
----------------
I don't think this is right. My expectation is that category records that need to get emitted would still have their own unique USR.


================
Comment at: clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp:759
+  // Check if the current Category Record has been visited before, if not add.
+  if (!(visitedCategories.contains(Record.Interface.Name) > 0)) {
+    visitedCategories.insert(Record.Interface.Name);
----------------
What happens when there are multiple categories to the same type though?


================
Comment at: clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp:775
+  Relationship["targetFallback"] = Record.Interface.Name;
+  Relationship["kind"] = getRelationshipString(RelationshipKind::MemberOf);
+  Relationships.emplace_back(std::move(Relationship));
----------------
I would expect this to be a new relationship kind that reads as "extensionTo"


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D152770/new/

https://reviews.llvm.org/D152770



More information about the cfe-commits mailing list