mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Removes the underscored prefixes from the @_section and @_used attributes, making them public as @section and @used respectively. The SymbolLinkageMarkers experimental feature has been removed as these attributes are now part of the standard language. Implemented expression syntactic checking rules per SE-0492. Major parts: - Renamed @_section to @section and @_used to @used - Removed the SymbolLinkageMarkers experimental feature - Added parsing support for the old underscored names with deprecation warnings - Updated all tests and examples to use the new attribute names - Added syntactic validation for @section to align with SE-0492 (reusing the legality checker by @artemcm) - Changed @DebugDescription macro to explicitly use a tuple type instead of type inferring it, to comply with the expression syntax rules - Added a testcase for the various allowed and disallowed syntactic forms, `test/ConstValues/SectionSyntactic.swift`.
58 lines
2.4 KiB
Swift
58 lines
2.4 KiB
Swift
// RUN: %target-swift-frontend -enable-experimental-feature CompileTimeValuesPreview -parse-as-library -emit-ir %s -o - | %FileCheck %s
|
|
|
|
// REQUIRES: swift_in_compiler
|
|
|
|
// Fails without optimized stdlib (rdar://119899895)
|
|
// REQUIRES: optimized_stdlib
|
|
// REQUIRES: swift_feature_CompileTimeValuesPreview
|
|
|
|
// The `StaticString("hello").utf8Start` test fails on 32 bit
|
|
// UNSUPPORTED: PTRSIZE=32
|
|
|
|
struct MyStruct1 {
|
|
var a, b: Int
|
|
}
|
|
@section("__TEXT,__mysection") var g_MyStruct1: MyStruct1 = MyStruct1(a: 42, b: 66)
|
|
|
|
struct MyStruct2 {
|
|
var a: Int
|
|
var b: (Int, Int)
|
|
}
|
|
@section("__TEXT,__mysection") var g_MyStruct2: MyStruct2 = MyStruct2(a: 42, b: (66, 67))
|
|
|
|
struct MyStruct3 {
|
|
var a, b: Int
|
|
public init(a: Int, b: Int) {
|
|
self.a = a
|
|
self.b = b
|
|
}
|
|
}
|
|
@section("__TEXT,__mysection") var g_MyStruct3: MyStruct3 = MyStruct3(a: 42, b: 77)
|
|
|
|
struct MyStruct4 {
|
|
var a: Int
|
|
var s: MyStruct1
|
|
}
|
|
@section("__TEXT,__mysection") var g_MyStruct4: MyStruct4 = MyStruct4(a: 42, s: MyStruct1(a: 43, b: 44))
|
|
|
|
struct MyStruct5 {
|
|
var q: MyStruct4
|
|
var r: MyStruct4
|
|
public init(q: MyStruct4, r: MyStruct4) {
|
|
self.q = q
|
|
self.r = r
|
|
}
|
|
}
|
|
@section("__TEXT,__mysection") var g_MyStruct5: MyStruct5 = MyStruct5(q: MyStruct4(a: 42, s: MyStruct1(a: 43, b: 44)), r: MyStruct4(a: 42, s: MyStruct1(a: 43, b: 44)))
|
|
|
|
@section("__TEXT,__mysection") let utf8OfStaticString = StaticString("hello").utf8Start
|
|
|
|
// CHECK: @"{{.*}}g_MyStruct1{{.*}}Vvp" = hidden global {{.*}} <{ %TSi <{ {{(i32|i64)}} 42 }>, %TSi <{ {{(i32|i64)}} 66 }> }>
|
|
// CHECK: @"{{.*}}g_MyStruct2{{.*}}Vvp" = hidden global {{.*}} <{ %TSi <{ {{(i32|i64)}} 42 }>, <{ %TSi, %TSi }> <{ %TSi <{ {{(i32|i64)}} 66 }>, %TSi <{ {{(i32|i64)}} 67 }> }> }>
|
|
// CHECK: @"{{.*}}g_MyStruct3{{.*}}Vvp" = hidden global {{.*}} <{ %TSi <{ {{(i32|i64)}} 42 }>, %TSi <{ {{(i32|i64)}} 77 }> }>
|
|
// CHECK: @"{{.*}}g_MyStruct4{{.*}}Vvp" = hidden global {{.*}} <{ %TSi <{ {{(i32|i64)}} 42 }>, {{.*}} <{ %TSi <{ {{(i32|i64)}} 43 }>, %TSi <{ {{(i32|i64)}} 44 }> }> }>
|
|
// CHECK: @"{{.*}}g_MyStruct5{{.*}}Vvp" = hidden global {{.*}} <{ {{.*}} <{ %TSi <{ {{(i32|i64)}} 42 }>, {{.*}} <{ %TSi <{ {{(i32|i64)}} 43 }>, %TSi <{ {{(i32|i64)}} 44 }> }> }>, {{.*}} <{ %TSi <{ {{(i32|i64)}} 42 }>, {{.*}} <{ %TSi <{ {{(i32|i64)}} 43 }>, %TSi <{ {{(i32|i64)}} 44 }> }> }> }>
|
|
|
|
// CHECK: [[HELLOSTR:@.*]] = private {{.*}}constant [6 x i8] c"hello\00"
|
|
// CHECK: @"{{.*}}utf8OfStaticString{{.*}}VGvp" = hidden constant {{.*}} <{ ptr [[HELLOSTR]] }>
|