[PATCH] D123261: [clang][ExtractAPI] Fix declaration fragments for ObjC methods

2022-04-07 Thread Zixu Wang via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG4048aad85a84: [clang][ExtractAPI] Fix declaration fragments 
for ObjC methods (authored by zixuw).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D123261

Files:
  clang/lib/ExtractAPI/DeclarationFragments.cpp
  clang/test/ExtractAPI/objc_category.m
  clang/test/ExtractAPI/objc_interface.m


Index: clang/test/ExtractAPI/objc_interface.m
===
--- clang/test/ExtractAPI/objc_interface.m
+++ clang/test/ExtractAPI/objc_interface.m
@@ -146,11 +146,7 @@
 },
 {
   "kind": "identifier",
-  "spelling": "getWithProperty"
-},
-{
-  "kind": "text",
-  "spelling": ":"
+  "spelling": "getWithProperty:"
 },
 {
   "kind": "text",
@@ -168,6 +164,10 @@
 {
   "kind": "internalParam",
   "spelling": "Property"
+},
+{
+  "kind": "text",
+  "spelling": ";"
 }
   ],
   "identifier": {
@@ -403,6 +403,10 @@
 {
   "kind": "identifier",
   "spelling": "getIvar"
+},
+{
+  "kind": "text",
+  "spelling": ";"
 }
   ],
   "identifier": {
Index: clang/test/ExtractAPI/objc_category.m
===
--- clang/test/ExtractAPI/objc_category.m
+++ clang/test/ExtractAPI/objc_category.m
@@ -136,6 +136,10 @@
 {
   "kind": "identifier",
   "spelling": "InstanceMethod"
+},
+{
+  "kind": "text",
+  "spelling": ";"
 }
   ],
   "identifier": {
@@ -190,6 +194,10 @@
 {
   "kind": "identifier",
   "spelling": "ClassMethod"
+},
+{
+  "kind": "text",
+  "spelling": ";"
 }
   ],
   "identifier": {
Index: clang/lib/ExtractAPI/DeclarationFragments.cpp
===
--- clang/lib/ExtractAPI/DeclarationFragments.cpp
+++ clang/lib/ExtractAPI/DeclarationFragments.cpp
@@ -593,20 +593,21 @@
 
   // For Objective-C methods that take arguments, build the selector slots.
   for (unsigned i = 0, end = Method->param_size(); i != end; ++i) {
-Fragments.appendSpace()
-.append(Selector.getNameForSlot(i),
-// The first slot is the name of the method, record as an
-// identifier, otherwise as exteranl parameters.
-i == 0 ? DeclarationFragments::FragmentKind::Identifier
-   : DeclarationFragments::FragmentKind::ExternalParam)
-.append(":", DeclarationFragments::FragmentKind::Text);
+// Objective-C method selector parts are considered as identifiers instead
+// of "external parameters" as in Swift. This is because Objective-C method
+// symbols are referenced with the entire selector, instead of just the
+// method name in Swift.
+SmallString<32> ParamID(Selector.getNameForSlot(i));
+ParamID.append(":");
+Fragments.appendSpace().append(
+ParamID, DeclarationFragments::FragmentKind::Identifier);
 
 // Build the internal parameter.
 const ParmVarDecl *Param = Method->getParamDecl(i);
 Fragments.append(getFragmentsForParam(Param));
   }
 
-  return Fragments;
+  return Fragments.append(";", DeclarationFragments::FragmentKind::Text);
 }
 
 DeclarationFragments DeclarationFragmentsBuilder::getFragmentsForObjCProperty(


Index: clang/test/ExtractAPI/objc_interface.m
===
--- clang/test/ExtractAPI/objc_interface.m
+++ clang/test/ExtractAPI/objc_interface.m
@@ -146,11 +146,7 @@
 },
 {
   "kind": "identifier",
-  "spelling": "getWithProperty"
-},
-{
-  "kind": "text",
-  "spelling": ":"
+  "spelling": "getWithProperty:"
 },
 {
   "kind": "text",
@@ -168,6 +164,10 @@
 {
   "kind": "internalParam",
   "spelling": "Property"
+},
+{
+  "kind": "text",
+  "spelling": ";"
 }
   ],
   "identifier": {
@@ -403,6 +403,10 @@
 {
   "kind": "identifier",
   "spelling": "getIvar"
+},
+{
+  "kind": "text",
+  "spelling": ";"
 }
   ],
   "identifier": {
Index: clang/test/ExtractAPI/objc_category.m
===
--- clang/test/ExtractAPI/objc_category.m
+++ clang/test/ExtractAPI/objc_category.m
@@ -136,6 +136,10 @@
 {
   "kind": "identifier",
   "spelling": "InstanceMethod"
+},
+{
+  "kind": "text",

[PATCH] D123261: [clang][ExtractAPI] Fix declaration fragments for ObjC methods

2022-04-07 Thread Daniel Grumberg via Phabricator via cfe-commits
dang accepted this revision.
dang added a comment.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D123261

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D123261: [clang][ExtractAPI] Fix declaration fragments for ObjC methods

2022-04-06 Thread Victoria Mitchell via Phabricator via cfe-commits
QuietMisdreavus accepted this revision.
QuietMisdreavus added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D123261

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D123261: [clang][ExtractAPI] Fix declaration fragments for ObjC methods

2022-04-06 Thread Zixu Wang via Phabricator via cfe-commits
zixuw created this revision.
Herald added a reviewer: dang.
Herald added a project: All.
zixuw requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Objective-C methods selector parts should be considered as identifiers.

Depends on D123259 


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D123261

Files:
  clang/lib/ExtractAPI/DeclarationFragments.cpp
  clang/test/ExtractAPI/objc_category.m
  clang/test/ExtractAPI/objc_interface.m


Index: clang/test/ExtractAPI/objc_interface.m
===
--- clang/test/ExtractAPI/objc_interface.m
+++ clang/test/ExtractAPI/objc_interface.m
@@ -146,11 +146,7 @@
 },
 {
   "kind": "identifier",
-  "spelling": "getWithProperty"
-},
-{
-  "kind": "text",
-  "spelling": ":"
+  "spelling": "getWithProperty:"
 },
 {
   "kind": "text",
@@ -168,6 +164,10 @@
 {
   "kind": "internalParam",
   "spelling": "Property"
+},
+{
+  "kind": "text",
+  "spelling": ";"
 }
   ],
   "identifier": {
@@ -403,6 +403,10 @@
 {
   "kind": "identifier",
   "spelling": "getIvar"
+},
+{
+  "kind": "text",
+  "spelling": ";"
 }
   ],
   "identifier": {
Index: clang/test/ExtractAPI/objc_category.m
===
--- clang/test/ExtractAPI/objc_category.m
+++ clang/test/ExtractAPI/objc_category.m
@@ -136,6 +136,10 @@
 {
   "kind": "identifier",
   "spelling": "InstanceMethod"
+},
+{
+  "kind": "text",
+  "spelling": ";"
 }
   ],
   "identifier": {
@@ -190,6 +194,10 @@
 {
   "kind": "identifier",
   "spelling": "ClassMethod"
+},
+{
+  "kind": "text",
+  "spelling": ";"
 }
   ],
   "identifier": {
Index: clang/lib/ExtractAPI/DeclarationFragments.cpp
===
--- clang/lib/ExtractAPI/DeclarationFragments.cpp
+++ clang/lib/ExtractAPI/DeclarationFragments.cpp
@@ -593,20 +593,21 @@
 
   // For Objective-C methods that take arguments, build the selector slots.
   for (unsigned i = 0, end = Method->param_size(); i != end; ++i) {
-Fragments.appendSpace()
-.append(Selector.getNameForSlot(i),
-// The first slot is the name of the method, record as an
-// identifier, otherwise as exteranl parameters.
-i == 0 ? DeclarationFragments::FragmentKind::Identifier
-   : DeclarationFragments::FragmentKind::ExternalParam)
-.append(":", DeclarationFragments::FragmentKind::Text);
+// Objective-C method selector parts are considered as identifiers instead
+// of "external parameters" as in Swift. This is because Objective-C method
+// symbols are referenced with the entire selector, instead of just the
+// method name in Swift.
+SmallString<32> ParamID(Selector.getNameForSlot(i));
+ParamID.append(":");
+Fragments.appendSpace().append(
+ParamID, DeclarationFragments::FragmentKind::Identifier);
 
 // Build the internal parameter.
 const ParmVarDecl *Param = Method->getParamDecl(i);
 Fragments.append(getFragmentsForParam(Param));
   }
 
-  return Fragments;
+  return Fragments.append(";", DeclarationFragments::FragmentKind::Text);
 }
 
 DeclarationFragments DeclarationFragmentsBuilder::getFragmentsForObjCProperty(


Index: clang/test/ExtractAPI/objc_interface.m
===
--- clang/test/ExtractAPI/objc_interface.m
+++ clang/test/ExtractAPI/objc_interface.m
@@ -146,11 +146,7 @@
 },
 {
   "kind": "identifier",
-  "spelling": "getWithProperty"
-},
-{
-  "kind": "text",
-  "spelling": ":"
+  "spelling": "getWithProperty:"
 },
 {
   "kind": "text",
@@ -168,6 +164,10 @@
 {
   "kind": "internalParam",
   "spelling": "Property"
+},
+{
+  "kind": "text",
+  "spelling": ";"
 }
   ],
   "identifier": {
@@ -403,6 +403,10 @@
 {
   "kind": "identifier",
   "spelling": "getIvar"
+},
+{
+  "kind": "text",
+  "spelling": ";"
 }
   ],
   "identifier": {
Index: clang/test/ExtractAPI/objc_category.m
===
--- clang/test/ExtractAPI/objc_category.m
+++ clang/test/ExtractAPI/objc_category.m
@@ -136,6 +136,10 @@
 {
   "kind": "identifier",
   "spelling": "InstanceMethod"
+},
+{
+  "