[PATCH] D123304: [clang][extract-api] Emit "functionSignature" in SGF for ObjC methods.

2022-04-11 Thread Daniel Grumberg via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
dang marked an inline comment as done.
Closed by commit rG236b6a0eb41a: [clang][extract-api] Emit 
functionSignature in SGF for ObjC methods. (authored by dang).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D123304

Files:
  clang/include/clang/ExtractAPI/API.h
  clang/include/clang/ExtractAPI/Serialization/SymbolGraphSerializer.h
  clang/lib/ExtractAPI/API.cpp
  clang/lib/ExtractAPI/ExtractAPIConsumer.cpp
  clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.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
@@ -182,6 +182,38 @@
   "spelling": ";"
 }
   ],
+  "functionSignature": {
+"parameters": [
+  {
+"declarationFragments": [
+  {
+"kind": "text",
+"spelling": "("
+  },
+  {
+"kind": "typeIdentifier",
+"preciseIdentifier": "c:i",
+"spelling": "unsigned int"
+  },
+  {
+"kind": "text",
+"spelling": ") "
+  },
+  {
+"kind": "internalParam",
+"spelling": "Property"
+  }
+],
+"name": "Property"
+  }
+],
+"returns": [
+  {
+"kind": "keyword",
+"spelling": "id"
+  }
+]
+  },
   "identifier": {
 "interfaceLanguage": "objective-c",
 "precise": "c:objc(cs)Super(cm)getWithProperty:"
@@ -288,6 +320,61 @@
   "spelling": ";"
 }
   ],
+  "functionSignature": {
+"parameters": [
+  {
+"declarationFragments": [
+  {
+"kind": "text",
+"spelling": "("
+  },
+  {
+"kind": "typeIdentifier",
+"preciseIdentifier": "c:i",
+"spelling": "unsigned int"
+  },
+  {
+"kind": "text",
+"spelling": ") "
+  },
+  {
+"kind": "internalParam",
+"spelling": "Property"
+  }
+],
+"name": "Property"
+  },
+  {
+"declarationFragments": [
+  {
+"kind": "text",
+"spelling": "("
+  },
+  {
+"kind": "typeIdentifier",
+"preciseIdentifier": "c:i",
+"spelling": "unsigned int"
+  },
+  {
+"kind": "text",
+"spelling": ") "
+  },
+  {
+"kind": "internalParam",
+"spelling": "Thing"
+  }
+],
+"name": "Thing"
+  }
+],
+"returns": [
+  {
+"kind": "typeIdentifier",
+"preciseIdentifier": "c:v",
+"spelling": "void"
+  }
+]
+  },
   "identifier": {
 "interfaceLanguage": "objective-c",
 "precise": "c:objc(cs)Super(im)setProperty:andOtherThing:"
@@ -551,6 +638,15 @@
   "spelling": ";"
 }
   ],
+  "functionSignature": {
+"returns": [
+  {
+"kind": "typeIdentifier",
+"preciseIdentifier": "c:C",
+"spelling": "char"
+  }
+]
+  },
   "identifier": {
 "interfaceLanguage": "objective-c",
 "precise": "c:objc(cs)Derived(im)getIvar"
Index: clang/test/ExtractAPI/objc_category.m
===
--- clang/test/ExtractAPI/objc_category.m
+++ clang/test/ExtractAPI/objc_category.m
@@ -148,6 +148,15 @@
   "spelling": ";"
 }
   ],
+  "functionSignature": {
+"returns": [
+  {
+"kind": "typeIdentifier",
+"preciseIdentifier": "c:v",
+"spelling": "void"
+  }
+]
+  },
   "identifier": {
 "interfaceLanguage": "objective-c",
 "precise": "c:objc(cs)Interface(im)InstanceMethod"
@@ -212,6 +221,15 @@
   "spelling": ";"
 }
   ],
+  "functionSignature": {
+"returns": [
+  {
+"kind": "typeIdentifier",
+"preciseIdentifier": "c:v",
+"spelling": "void"
+  }
+]
+  },
   "identifier": {
 "interfaceLanguage": "objective-c",
 "precise": 

[PATCH] D123304: [clang][extract-api] Emit "functionSignature" in SGF for ObjC methods.

2022-04-11 Thread Zixu Wang via Phabricator via cfe-commits
zixuw accepted this revision.
zixuw 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/D123304/new/

https://reviews.llvm.org/D123304

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


[PATCH] D123304: [clang][extract-api] Emit "functionSignature" in SGF for ObjC methods.

2022-04-11 Thread Daniel Grumberg via Phabricator via cfe-commits
dang marked an inline comment as done.
dang added inline comments.



Comment at: clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp:495
 
+if (const auto *Method = dyn_cast(Member.get()))
+  serializeObject(*MemberRecord, "functionSignature",

zixuw wrote:
> dang wrote:
> > zixuw wrote:
> > > I'd prefer not to use `dyn_cast` as `MemberTy` here is a concrete type. 
> > > So maybe a type trait `has_function_signature` and a `if constexpr`?
> > `if constexpr` is c++17 which we don't support yet? Anyway I added the type 
> > trait and implemented this a bit lower down the "stack" (in 
> > serializeAPIRecord) as there are multiple record types that have 
> > signatures. This is done using tag dispatch based on the trait.
> Hmm.. That's a bummer. Didn't realize that when I made the suggestion. I 
> actually don't have that strong an opinion regarding the `dyn_cast`.
> What do you think? Do you think it's still worth going through all these to 
> get the type trait working?
I think it is still worth it, so that we can emit function signatures in 
APIRecord as multiple types of records need them (and the list of records will 
keep growing). This could be a useful way of dealing with things like 
availability information as well.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D123304

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


[PATCH] D123304: [clang][extract-api] Emit "functionSignature" in SGF for ObjC methods.

2022-04-11 Thread Zixu Wang via Phabricator via cfe-commits
zixuw added inline comments.



Comment at: clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp:495
 
+if (const auto *Method = dyn_cast(Member.get()))
+  serializeObject(*MemberRecord, "functionSignature",

dang wrote:
> zixuw wrote:
> > I'd prefer not to use `dyn_cast` as `MemberTy` here is a concrete type. So 
> > maybe a type trait `has_function_signature` and a `if constexpr`?
> `if constexpr` is c++17 which we don't support yet? Anyway I added the type 
> trait and implemented this a bit lower down the "stack" (in 
> serializeAPIRecord) as there are multiple record types that have signatures. 
> This is done using tag dispatch based on the trait.
Hmm.. That's a bummer. Didn't realize that when I made the suggestion. I 
actually don't have that strong an opinion regarding the `dyn_cast`.
What do you think? Do you think it's still worth going through all these to get 
the type trait working?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D123304

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


[PATCH] D123304: [clang][extract-api] Emit "functionSignature" in SGF for ObjC methods.

2022-04-11 Thread Daniel Grumberg via Phabricator via cfe-commits
dang added inline comments.



Comment at: clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp:495
 
+if (const auto *Method = dyn_cast(Member.get()))
+  serializeObject(*MemberRecord, "functionSignature",

zixuw wrote:
> I'd prefer not to use `dyn_cast` as `MemberTy` here is a concrete type. So 
> maybe a type trait `has_function_signature` and a `if constexpr`?
`if constexpr` is c++17 which we don't support yet? Anyway I added the type 
trait and implemented this a bit lower down the "stack" (in serializeAPIRecord) 
as there are multiple record types that have signatures. This is done using tag 
dispatch based on the trait.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D123304

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


[PATCH] D123304: [clang][extract-api] Emit "functionSignature" in SGF for ObjC methods.

2022-04-11 Thread Daniel Grumberg via Phabricator via cfe-commits
dang updated this revision to Diff 421932.
dang added a comment.

Address code review feedback.

Introduce `has_function_signature` type trait to distinguish records that have a
function signatures.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D123304

Files:
  clang/include/clang/ExtractAPI/API.h
  clang/include/clang/ExtractAPI/Serialization/SymbolGraphSerializer.h
  clang/lib/ExtractAPI/API.cpp
  clang/lib/ExtractAPI/ExtractAPIConsumer.cpp
  clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.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
@@ -182,6 +182,38 @@
   "spelling": ";"
 }
   ],
+  "functionSignature": {
+"parameters": [
+  {
+"declarationFragments": [
+  {
+"kind": "text",
+"spelling": "("
+  },
+  {
+"kind": "typeIdentifier",
+"preciseIdentifier": "c:i",
+"spelling": "unsigned int"
+  },
+  {
+"kind": "text",
+"spelling": ") "
+  },
+  {
+"kind": "internalParam",
+"spelling": "Property"
+  }
+],
+"name": "Property"
+  }
+],
+"returns": [
+  {
+"kind": "keyword",
+"spelling": "id"
+  }
+]
+  },
   "identifier": {
 "interfaceLanguage": "objective-c",
 "precise": "c:objc(cs)Super(cm)getWithProperty:"
@@ -288,6 +320,61 @@
   "spelling": ";"
 }
   ],
+  "functionSignature": {
+"parameters": [
+  {
+"declarationFragments": [
+  {
+"kind": "text",
+"spelling": "("
+  },
+  {
+"kind": "typeIdentifier",
+"preciseIdentifier": "c:i",
+"spelling": "unsigned int"
+  },
+  {
+"kind": "text",
+"spelling": ") "
+  },
+  {
+"kind": "internalParam",
+"spelling": "Property"
+  }
+],
+"name": "Property"
+  },
+  {
+"declarationFragments": [
+  {
+"kind": "text",
+"spelling": "("
+  },
+  {
+"kind": "typeIdentifier",
+"preciseIdentifier": "c:i",
+"spelling": "unsigned int"
+  },
+  {
+"kind": "text",
+"spelling": ") "
+  },
+  {
+"kind": "internalParam",
+"spelling": "Thing"
+  }
+],
+"name": "Thing"
+  }
+],
+"returns": [
+  {
+"kind": "typeIdentifier",
+"preciseIdentifier": "c:v",
+"spelling": "void"
+  }
+]
+  },
   "identifier": {
 "interfaceLanguage": "objective-c",
 "precise": "c:objc(cs)Super(im)setProperty:andOtherThing:"
@@ -551,6 +638,15 @@
   "spelling": ";"
 }
   ],
+  "functionSignature": {
+"returns": [
+  {
+"kind": "typeIdentifier",
+"preciseIdentifier": "c:C",
+"spelling": "char"
+  }
+]
+  },
   "identifier": {
 "interfaceLanguage": "objective-c",
 "precise": "c:objc(cs)Derived(im)getIvar"
Index: clang/test/ExtractAPI/objc_category.m
===
--- clang/test/ExtractAPI/objc_category.m
+++ clang/test/ExtractAPI/objc_category.m
@@ -148,6 +148,15 @@
   "spelling": ";"
 }
   ],
+  "functionSignature": {
+"returns": [
+  {
+"kind": "typeIdentifier",
+"preciseIdentifier": "c:v",
+"spelling": "void"
+  }
+]
+  },
   "identifier": {
 "interfaceLanguage": "objective-c",
 "precise": "c:objc(cs)Interface(im)InstanceMethod"
@@ -212,6 +221,15 @@
   "spelling": ";"
 }
   ],
+  "functionSignature": {
+"returns": [
+  {
+"kind": "typeIdentifier",
+"preciseIdentifier": "c:v",
+"spelling": "void"
+  }
+]
+  },
   "identifier": {
 "interfaceLanguage": "objective-c",
 "precise": "c:objc(cs)Interface(cm)ClassMethod"
Index: clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp

[PATCH] D123304: [clang][extract-api] Emit "functionSignature" in SGF for ObjC methods.

2022-04-07 Thread Zixu Wang via Phabricator via cfe-commits
zixuw added inline comments.



Comment at: clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp:495
 
+if (const auto *Method = dyn_cast(Member.get()))
+  serializeObject(*MemberRecord, "functionSignature",

I'd prefer not to use `dyn_cast` as `MemberTy` here is a concrete type. So 
maybe a type trait `has_function_signature` and a `if constexpr`?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D123304

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


[PATCH] D123304: [clang][extract-api] Emit "functionSignature" in SGF for ObjC methods.

2022-04-07 Thread Daniel Grumberg via Phabricator via cfe-commits
dang created this revision.
dang added reviewers: zixuw, QuietMisdreavus.
Herald added a project: All.
dang requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D123304

Files:
  clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.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
@@ -170,6 +170,38 @@
   "spelling": "Property"
 }
   ],
+  "functionSignature": {
+"parameters": [
+  {
+"declarationFragments": [
+  {
+"kind": "text",
+"spelling": "("
+  },
+  {
+"kind": "typeIdentifier",
+"preciseIdentifier": "c:i",
+"spelling": "unsigned int"
+  },
+  {
+"kind": "text",
+"spelling": ")"
+  },
+  {
+"kind": "internalParam",
+"spelling": "Property"
+  }
+],
+"name": "Property"
+  }
+],
+"returns": [
+  {
+"kind": "keyword",
+"spelling": "id"
+  }
+]
+  },
   "identifier": {
 "interfaceLanguage": "objective-c",
 "precise": "c:objc(cs)Super(cm)getWithProperty:"
@@ -405,6 +437,15 @@
   "spelling": "getIvar"
 }
   ],
+  "functionSignature": {
+"returns": [
+  {
+"kind": "typeIdentifier",
+"preciseIdentifier": "c:C",
+"spelling": "char"
+  }
+]
+  },
   "identifier": {
 "interfaceLanguage": "objective-c",
 "precise": "c:objc(cs)Derived(im)getIvar"
Index: clang/test/ExtractAPI/objc_category.m
===
--- clang/test/ExtractAPI/objc_category.m
+++ clang/test/ExtractAPI/objc_category.m
@@ -138,6 +138,15 @@
   "spelling": "InstanceMethod"
 }
   ],
+  "functionSignature": {
+"returns": [
+  {
+"kind": "typeIdentifier",
+"preciseIdentifier": "c:v",
+"spelling": "void"
+  }
+]
+  },
   "identifier": {
 "interfaceLanguage": "objective-c",
 "precise": "c:objc(cs)Interface(im)InstanceMethod"
@@ -192,6 +201,15 @@
   "spelling": "ClassMethod"
 }
   ],
+  "functionSignature": {
+"returns": [
+  {
+"kind": "typeIdentifier",
+"preciseIdentifier": "c:v",
+"spelling": "void"
+  }
+]
+  },
   "identifier": {
 "interfaceLanguage": "objective-c",
 "precise": "c:objc(cs)Interface(cm)ClassMethod"
Index: clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp
===
--- clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp
+++ clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp
@@ -14,6 +14,7 @@
 #include "clang/ExtractAPI/Serialization/SymbolGraphSerializer.h"
 #include "clang/Basic/Version.h"
 #include "clang/ExtractAPI/API.h"
+#include "llvm/Support/Casting.h"
 #include "llvm/Support/JSON.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/VersionTuple.h"
@@ -491,6 +492,10 @@
 if (!MemberRecord)
   continue;
 
+if (const auto *Method = dyn_cast(Member.get()))
+  serializeObject(*MemberRecord, "functionSignature",
+  serializeFunctionSignature(Method->Signature));
+
 Symbols.emplace_back(std::move(*MemberRecord));
 serializeRelationship(RelationshipKind::MemberOf, *Member, Record);
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits