File: existential-bitwise-borrowability.swift

package info (click to toggle)
swiftlang 6.1.3-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,791,532 kB
  • sloc: cpp: 9,901,743; ansic: 2,201,431; asm: 1,091,827; python: 308,252; objc: 82,166; f90: 80,126; lisp: 38,358; pascal: 25,559; sh: 20,429; ml: 5,058; perl: 4,745; makefile: 4,484; awk: 3,535; javascript: 3,018; xml: 918; fortran: 664; cs: 573; ruby: 396
file content (41 lines) | stat: -rw-r--r-- 1,738 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
// RUN: %empty-directory(%t)
// RUN: %{python} %utils/chex.py < %s > %t/existential-bitwise-borrowability.swift
// RUN: %target-swift-frontend -enable-experimental-feature RawLayout -enable-experimental-feature ValueGenerics -emit-ir -disable-availability-checking -I %S/Inputs -cxx-interoperability-mode=upcoming-swift %t/existential-bitwise-borrowability.swift | %FileCheck %t/existential-bitwise-borrowability.swift --check-prefix=CHECK --check-prefix=CHECK-%target-ptrsize

// REQUIRES: swift_feature_RawLayout
// REQUIRES: swift_feature_ValueGenerics

// Copyable existentials are bitwise-borrowable (because copyable types are
// always bitwise-borrowable if they're bitwise-takable, and only bitwise-takable
// values are stored inline in existentials). Noncopyable existentials are
// not (since types like Atomic and Mutex can be stored inline in their
// buffers).

// CHECK-LABEL: @"$s{{[A-Za-z0-9_]*}}3FooVWV" = {{.*}} %swift.vwtable
// size
// CHECK-64-SAME:  , {{i64|i32}} 32
// CHECK-32-SAME:  , {{i64|i32}} 16
// stride
// CHECK-64-SAME:  , {{i64|i32}} 32
// CHECK-32-SAME:  , {{i64|i32}} 16
// flags: word alignment, noncopyable, non-POD, non-inline-storage
// CHECK-64-SAME:  , <i32 0x830007>
// CHECK-32-SAME:  , <i32 0x830003>
struct Foo: ~Copyable {
    var x: Any
}

// CHECK-LABEL: @"$s{{[A-Za-z0-9_]*}}3BarVWV" = {{.*}} %swift.vwtable
// size
// CHECK-64-SAME:  , {{i64|i32}} 32
// CHECK-32-SAME:  , {{i64|i32}} 16
// stride
// CHECK-64-SAME:  , {{i64|i32}} 32
// CHECK-32-SAME:  , {{i64|i32}} 16
// flags: word alignment, non-bitwise-borrowable, noncopyable, non-POD, non-inline-storage
// CHECK-64-SAME:  , <i32 0x1830007>
// CHECK-32-SAME:  , <i32 0x1830003>
struct Bar: ~Copyable {
    var x: any ~Copyable
}