Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[clang] Add Obj-C bridging-related attributes to C-Index API #69899

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

jevinskie
Copy link

Yowza, I haven't tried to upstream anything to LLVM in a long time. It was so long ago I just had my coworker submit it for me with their SVN access...

Anyways, this adds ObjCBridgeAttr, ObjCBridgeMutableAttr, and ObjCBridgeRelatedAttr attributes to C-Index (c-index? C-index?). Truth be told, I just wanted a way to figure out that a SecKeyRef parameter in a header was usable as an Obj-C object.

Now c-index-test -test-print-type -Xclang -triple -Xclang arm64-apple-ios17.0.0 -x objective-c ./objc-bridge-attr-test.h prints:

<pre-defined macro definition spam>
...
ObjCClassRef=Protocol:0:0 [type=Protocol] [typekind=ObjCInterface] [isPOD=0] [isAnonRecDecl=0]
StructDecl=__SecKey:3:60 [type=struct __SecKey] [typekind=Record] [isPOD=0] [isAnonRecDecl=0]
attribute(packed)=packed [type=] [typekind=Invalid] [isPOD=0] [isAnonRecDecl=0]
ObjCBridgeAttr= [type=] [typekind=Invalid] [isPOD=0] [isAnonRecDecl=0]
TypedefDecl=SecKeyRef:3:70 (Definition) [type=SecKeyRef] [typekind=Typedef] [canonicaltype=struct __SecKey *] [canonicaltypekind=Pointer] [isPOD=1] [isAnonRecDecl=0]
TypeRef=struct __SecKey:3:60 [type=struct __SecKey] [typekind=Record] [isPOD=0] [isAnonRecDecl=0]
FunctionDecl=i_take_a_key:5:12 [type=int (SecKeyRef)] [typekind=FunctionProto] [canonicaltype=int (struct __SecKey *)] [canonicaltypekind=FunctionProto] [resulttype=int] [resulttypekind=Int] [args= [SecKeyRef] [Elaborated]] [isPOD=0] [isAnonRecDecl=0]
ParmDecl=my_key:5:35 (Definition) [type=SecKeyRef] [typekind=Elaborated] [canonicaltype=struct __SecKey *] [canonicaltypekind=Pointer] [isPOD=1] [isAnonRecDecl=0]
TypeRef=SecKeyRef:3:70 [type=SecKeyRef] [typekind=Typedef] [canonicaltype=struct __SecKey *] [canonicaltypekind=Pointer] [isPOD=1] [isAnonRecDecl=0]

with objc-bridge-attr-test.h:

#define CF_BRIDGED_TYPE(T) __attribute__((objc_bridge(T)))

typedef struct __attribute__((packed)) CF_BRIDGED_TYPE(id) __SecKey *SecKeyRef;

extern int i_take_a_key(SecKeyRef my_key);

(That is not the true typedef of SecKeyRef, I just threw another, already supported, __attribute__((packed)) in there for testing.)

Speaking of testing, do all new CXCursorKind enums need unit tests written for them?

Thanks and long live the Dragon.

@llvmbot llvmbot added the clang Clang issues not falling into any other category label Oct 23, 2023
@jevinskie jevinskie changed the title Add Obj-C bridging-related attributes to C-Index API [clang] Add Obj-C bridging-related attributes to C-Index API Oct 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang Clang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants