Skip to content

LLVM/Clang does not process visionOS (xros) availability correctly #142502

Open
@stuartcarnie

Description

@stuartcarnie

The following snippet of Objective-C code, which declares the typedef as available on watchOS, and unavailable on iOS, macOS and tvOS platforms:

#import <Foundation/Foundation.h>

API_UNAVAILABLE(visionos) @interface Foo
@end

typedef void(^Bar)(Foo *foo) API_AVAILABLE(watchos(5.0)) API_UNAVAILABLE(ios,macos,tvos);

Given iOS is unavailable, it also includes derivatives, which means visionOS.

Compiling this snippet with Apple's clang compiler works as expected:

echo "#import <Foundation/Foundation.h>\nAPI_UNAVAILABLE(visionos) @interface Foo\n@end\n typedef void(^Bar)(Foo *foo) API_AVAILABLE(watchos(5.0)) API_UNAVAILABLE(ios,macos,tvos);" | xcrun -sdk xros clang -mtargetos=xros2.5 -O2 -x objective-c -c -o test.o -

However, compiling with clang from here fails:

echo -e "#import <Foundation/Foundation.h>\nAPI_UNAVAILABLE(visionos) @interface Foo\n@end\ntypedef void(^Bar)(Foo *foo) API_AVAILABLE(watchos(5.0)) API_UNAVAILABLE(ios,macos,tvos);" | arm-apple-darwin11-clang -isysroot /root/SDKs/XROS2.5.sdk/ -mtargetos=xros2.5 -O2 -x objective-c -c -o test.o -

Output:

<stdin>:4:20: error: 'Foo' is unavailable: not available on visionOS
    4 | typedef void(^Bar)(Foo *foo) API_AVAILABLE(watchos(5.0)) API_UNAVAILABLE(ios,macos,tvos);
      |                    ^                                                                                                                                          <stdin>:2:38: note: 'Foo' has been explicitly marked unavailable here                                                                                                     2 | API_UNAVAILABLE(visionos) @interface Foo
      |                                      ^
1 error generated.

If I explicitly add visionos to the typedef declaration, it passes.

Unfortunately, this problem occurs when compiling Apple's SDKs, such as CoreMotion with llvm / clang, that has declarations such as:

/*!
 * @typedef CMDyskineticSymptomResultHandler
 * @brief Completion handler for CMDyskineticSymptomResult values.
 */
typedef void(^CMDyskineticSymptomResultHandler)(NSArray<CMDyskineticSymptomResult *> * _Nonnull dyskineticSymptomResult, NSError * _Nullable error) API_AVAILABLE(watchos(5.0)) API_UNAVAILABLE(ios, macos, tvos);

Metadata

Metadata

Assignees

No one assigned

    Labels

    clang:driver'clang' and 'clang++' user-facing binaries. Not 'clang-cl'platform:iosiOS-related issues

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions