gnustep / libobjc2

Objective-C runtime library intended for use with Clang.
http://www.gnustep.org/
MIT License
426 stars 116 forks source link

Add returns-retained annotation to class_createInstance. #229

Closed davidchisnall closed 1 year ago

davidchisnall commented 1 year ago

I'm a bit confused. With this change, clang generates the right IR for me. The error is coming from C files, where id is struct objc_object* and so isn't treated as an Objective-C type. We should gate that attribute on defined(__OBJC__).

triplef commented 1 year ago

Sorry, you are correct. The change does fix the issue mentioned in https://github.com/llvm/llvm-project/issues/56056.

Also using #if defined(__OBJC__) && __has_attribute(ns_returns_retained) will fix the warnings.

I was looking at another crash with LLVM 14 when accessing GNUstep Base classes for the first time (e.g. calling [NSUserDefaults standardUserDefaults] crashes in _objc_block_trampoline_end_sret), which I incorrectly thought was the same issue. I will look into that in more detail and report it separately.