llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
29.03k stars 11.96k forks source link

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

Open daniel-grumberg opened 1 year ago

daniel-grumberg commented 1 year ago

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.

llvmbot commented 1 year ago

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

crnsh commented 1 year ago

I'd like to work on this.

daniel-grumberg commented 1 year ago

Go for it!

daniel-grumberg commented 1 year ago

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

ayushi-8102 commented 1 year ago

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

crnsh commented 1 year ago

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

Sparks0219 commented 1 year ago

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

Unique-Usman commented 1 year ago

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

Shanchax commented 1 year ago

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

felixkellenbenz commented 12 months ago

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

felixkellenbenz commented 11 months ago

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.

daniel-grumberg commented 11 months ago

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.

felixkellenbenz commented 11 months ago

Thank you!