[clang] 05b4bfe - [ExtractAPI] Include +/- symbols for ObjC methods (#145035)
via cfe-commits
cfe-commits at lists.llvm.org
Fri Jun 20 08:05:19 PDT 2025
Author: Prajwal Nadig
Date: 2025-06-20T09:05:16-06:00
New Revision: 05b4bfe19eaba13b4fdf39fc5541077c255b8e3f
URL: https://github.com/llvm/llvm-project/commit/05b4bfe19eaba13b4fdf39fc5541077c255b8e3f
DIFF: https://github.com/llvm/llvm-project/commit/05b4bfe19eaba13b4fdf39fc5541077c255b8e3f.diff
LOG: [ExtractAPI] Include +/- symbols for ObjC methods (#145035)
ObjC methods include a +/- prefix to indicate if they are a class or
instance method. This information is valuable, and must be included in
the navigator generated by ExtractAPI.
rdar://150870936
Added:
Modified:
clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp
clang/test/ExtractAPI/objc_instancetype.m
Removed:
################################################################################
diff --git a/clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp b/clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp
index 139023f32e8d3..d3df9eb604f27 100644
--- a/clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp
+++ b/clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp
@@ -341,6 +341,22 @@ Object serializeNames(const APIRecord *Record) {
serializeArray(Names, "subHeading",
serializeDeclarationFragments(Record->SubHeading));
DeclarationFragments NavigatorFragments;
+ // The +/- prefix for Objective-C methods is important information, and
+ // should be included in the navigator fragment. The entire subheading is
+ // not included as it can contain too much information for other records.
+ switch (Record->getKind()) {
+ case APIRecord::RK_ObjCClassMethod:
+ NavigatorFragments.append("+ ", DeclarationFragments::FragmentKind::Text,
+ /*PreciseIdentifier*/ "");
+ break;
+ case APIRecord::RK_ObjCInstanceMethod:
+ NavigatorFragments.append("- ", DeclarationFragments::FragmentKind::Text,
+ /*PreciseIdentifier*/ "");
+ break;
+ default:
+ break;
+ }
+
NavigatorFragments.append(Record->Name,
DeclarationFragments::FragmentKind::Identifier,
/*PreciseIdentifier*/ "");
diff --git a/clang/test/ExtractAPI/objc_instancetype.m b/clang/test/ExtractAPI/objc_instancetype.m
index 071ebe440918a..dbd47a1f746ff 100644
--- a/clang/test/ExtractAPI/objc_instancetype.m
+++ b/clang/test/ExtractAPI/objc_instancetype.m
@@ -157,6 +157,10 @@ - (id) reset;
},
"names": {
"navigator": [
+ {
+ "kind": "text",
+ "spelling": "- "
+ },
{
"kind": "identifier",
"spelling": "init"
@@ -228,6 +232,10 @@ - (id) reset;
},
"names": {
"navigator": [
+ {
+ "kind": "text",
+ "spelling": "- "
+ },
{
"kind": "identifier",
"spelling": "reset"
More information about the cfe-commits
mailing list