llvm-project icon indicating copy to clipboard operation
llvm-project copied to clipboard

[clang][ExtractAPI] Declaration fragments should show types as shown in the source code.

Open daniel-grumberg opened this issue 3 years ago • 16 comments

For Objective-C APIs that use typedefs, ExtractAPI emits declarations with the original’s type’s name rather than its typedef name.

For example, in:

typedef struct MyStruct * MyTypeDef;

void foo(MyTypeDef x) {}

The declaration for foo is the following:

void foo(struct MyStruct * x)

Rather than:

void foo(MyTypeDef x)

Resolving this issue will align the declaration we generate to the one that’s in the original source code.

daniel-grumberg avatar Mar 03 '23 15:03 daniel-grumberg

@llvm/issue-subscribers-good-first-issue

llvmbot avatar Mar 03 '23 15:03 llvmbot

I'd like to work on this.

ShriKaranHanda avatar Mar 07 '23 05:03 ShriKaranHanda

Go for it!

daniel-grumberg avatar Mar 10 '23 08:03 daniel-grumberg

Hey @karan0handa feel free to reach out to me if you need any help with this.

daniel-grumberg avatar Mar 14 '23 11:03 daniel-grumberg

Hey @karan0handa are you still working on this? I would also like to work on this issue!

ayushi-8102 avatar Mar 14 '23 22:03 ayushi-8102

I'm not working on this anymore. Feel free to take it up! @ayushi-8102

ShriKaranHanda avatar Mar 28 '23 05:03 ShriKaranHanda

I'd like to give this a shot if no one has found a fix yet

Sparks0219 avatar Apr 01 '23 06:04 Sparks0219

Anyone working, I will like to work on it, I have work on one issue which involve ExtractAPI before.

Unique-Usman avatar Apr 26 '23 19:04 Unique-Usman

Hi , anyone still working on it ? if not I'd like to have a crack at it. I am a beginner so advice and help would be most welcome and appreciated

Shanchax avatar Jul 04 '23 08:07 Shanchax

Hey, is anyone still working on this issue ? If not I would like to give it a try.

ghost avatar Nov 15 '23 19:11 ghost

Hey @daniel-grumberg I think this is issue is already solved. Here is the output I get when reproducing your example: The command I used was clang -x objective-c -extract-api test.h test.h

typedef struct MyStruct
{

} MyTypDef;

void func(MyTypDef *typ);

output.json

# 1 "test.h"
# 1 "<built-in>" 1
# 1 "<built-in>" 3
# 395 "<built-in>" 3
# 1 "<command line>" 1
# 1 "<built-in>" 2
# 1 "test.h" 2
typedef struct MyStruct
{

} MyTypDef;

void func(MyTypDef *typ);

The declaration of func emitted by ExtractAPI is already using the typdefs name.

ghost avatar Nov 19 '23 20:11 ghost

Sorry I think the description is not quite detailed enough, this happens when a typedef to a type related to the struct is used exactly as per the example in the original description of the issue.

daniel-grumberg avatar Nov 20 '23 15:11 daniel-grumberg

Thank you!

ghost avatar Nov 20 '23 17:11 ghost

Hi, I would love to work on this issue

shivam-dhir avatar Jan 22 '26 06:01 shivam-dhir

Hi, I was looking at this, and it looks like it has already been fixed? I copied the example exactly to test.h, and the output to command

clang -extract-api -x objective-c test.h

# 1 "test.h"
# 1 "<built-in>" 1
# 1 "<built-in>" 3
# 419 "<built-in>" 3
# 1 "<command line>" 1
# 1 "<built-in>" 2
# 1 "test.h" 2
typedef struct MyStruct *MyTypeDef;

void foo(MyTypeDef x) {}

Let me know if I am misunderstanding the issue. Thank you!

maomao9-0 avatar May 19 '26 13:05 maomao9-0

Hi, I'm looking at this for the CS3423 Compilers II hackathon at IIT Hyderabad. I see #167319 is open but looks stalled. Is it still being worked on, or is it okay if I take this over?

anupchavan avatar Oct 19 '26 07:10 anupchavan