Files
swift-mirror/test/IRGen/objc_globals.swift
Artem Chikin 1f14158a1d Introduce VisionOS Platform
This change introduces a new compilation target platform to the Swift compiler - visionOS.

- Changes to the compiler build infrastrucuture to support building compiler-adjacent artifacts and test suites for the new target.
- Addition of the new platform kind definition.
- Support for the new platform in language constructs such as compile-time availability annotations or runtime OS version queries.
- Utilities to read out Darwin platform SDK info containing platform mapping data.
- Utilities to support re-mapping availability annotations from iOS to visionOS (e.g. 'updateIntroducedPlatformForFallback', 'updateDeprecatedPlatformForFallback', 'updateObsoletedPlatformForFallback').
- Additional tests exercising platform-specific availability handling and availability re-mapping fallback code-path.
- Changes to existing test suite to accomodate the new platform.
2024-04-10 09:38:02 -07:00

47 lines
1.7 KiB
Swift

// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -I %S/Inputs/abi %s -whole-module-optimization -emit-ir | %FileCheck %s
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -I %S/Inputs/abi %s -emit-ir | %FileCheck %s
//
// REQUIRES: objc_interop
// UNSUPPORTED: OS=xros
import gadget
import Foundation
@inline(never)
func blackHole<T>(_ t: T) { }
// CHECK-DAG: @"OBJC_CLASS_$_NSNumber" = external global %struct._class_t
// CHECK-DAG: @"OBJC_CLASS_$_NSString" = external global %struct._class_t
// CHECK-DAG: @"OBJC_CLASSLIST_REFERENCES_$_{{.*}}" = internal global ptr @"OBJC_CLASS_$_NSNumber", section "__DATA,__objc_classrefs,regular,no_dead_strip"
// CHECK-DAG: @"OBJC_CLASSLIST_REFERENCES_$_{{.*}}" = internal global ptr @"OBJC_CLASS_$_NSString", section "__DATA,__objc_classrefs,regular,no_dead_strip"
public func testLiterals() {
blackHole(gadget.giveMeASelector())
blackHole(gadget.giveMeANumber())
blackHole(gadget.giveMeAMetaclass())
}
func fooInternal() {
blackHole(NSString.self as AnyObject)
}
public func fooLazy() {
fooInternal()
}
// CHECK-LABEL: define internal ptr @giveMeASelector()
// CHECK: load ptr, ptr @OBJC_SELECTOR_REFERENCES_
// CHECK: ret
// CHECK-LABEL: define internal ptr @giveMeANumber()
// CHECK: [[CLASS:%.*]] = load ptr, ptr
// CHECK-DAG: [[SELECTOR:%.*]] = load ptr, ptr @OBJC_SELECTOR_REFERENCES_.{{.*}}
// CHECK: call {{.*}} @objc_msgSend
// CHECK: ret
// CHECK-LABEL: define internal ptr @giveMeAMetaclass()
// CHECK: [[CLASS:%.*]] = load ptr, ptr
// CHECK-DAG: [[SELECTOR:%.*]] = load ptr, ptr @OBJC_SELECTOR_REFERENCES_
// CHECK: call {{.*}} @objc_msgSend
// CHECK: ret