Files
swift-mirror/test/IRGen/used.swift
Kuba Mracek adeb40f261 SE-0492: Stabilize @_section/@_used into @section/@used
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`.
2025-10-22 16:05:39 -07:00

33 lines
1.6 KiB
Swift

// RUN: %target-swift-frontend -primary-file %s -emit-sil | %FileCheck %s --check-prefix=SIL
// RUN: %target-swift-frontend -primary-file %s -O -emit-sil | %FileCheck %s --check-prefix=SIL
// RUN: %target-swift-frontend -primary-file %s -emit-ir | %FileCheck %s --check-prefix=IR
// RUN: %target-swift-frontend -primary-file %s -O -emit-ir | %FileCheck %s --check-prefix=IR
// RUN: %target-swift-frontend -primary-file %s -emit-sil -parse-as-library | %FileCheck %s --check-prefix=SIL
// RUN: %target-swift-frontend -primary-file %s -O -emit-sil -parse-as-library | %FileCheck %s --check-prefix=SIL
// RUN: %target-swift-frontend -primary-file %s -emit-ir -parse-as-library | %FileCheck %s --check-prefix=IR
// RUN: %target-swift-frontend -primary-file %s -O -emit-ir -parse-as-library | %FileCheck %s --check-prefix=IR
// REQUIRES: swift_in_compiler
@used var g0: Int = 1
@used var g1: (Int, Int) = (42, 43)
@used var g2: Bool = true
@used func foo() {}
// SIL: @used @_hasStorage @_hasInitialValue var g0: Int { get set }
// SIL: @used @_hasStorage @_hasInitialValue var g1: (Int, Int) { get set }
// SIL: @used @_hasStorage @_hasInitialValue var g2: Bool { get set }
// SIL: @used func foo()
// SIL: sil_global hidden [used] @$s4used2g0Sivp : $Int
// SIL: sil_global hidden [used] @$s4used2g1Si_Sitvp : $(Int, Int)
// SIL: sil_global hidden [used] @$s4used2g2Sbvp : $Bool
// SIL: sil hidden [used] @$s4used3fooyyF : $@convention(thin)
// IR: @llvm{{(\.compiler)?}}.used = appending global [{{.*}} x ptr] [
// IR-SAME: ptr @"$s4used2g0Sivp"
// IR-SAME: ptr @"$s4used2g1Si_Sitvp"
// IR-SAME: ptr @"$s4used2g2Sbvp"
// IR-SAME: ptr @"$s4used3fooyyF"