llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clang Author: Prajwal Nadig (snprajwal) <details> <summary>Changes</summary> 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 --- Full diff: https://github.com/llvm/llvm-project/pull/145035.diff 2 Files Affected: - (modified) clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp (+16) - (modified) clang/test/ExtractAPI/objc_instancetype.m (+8) ``````````diff 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" `````````` </details> https://github.com/llvm/llvm-project/pull/145035 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits