File: check_class_for_archiving_log.swift

package info (click to toggle)
swiftlang 6.0.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,519,992 kB
  • sloc: cpp: 9,107,863; ansic: 2,040,022; asm: 1,135,751; python: 296,500; objc: 82,456; f90: 60,502; lisp: 34,951; pascal: 19,946; sh: 18,133; perl: 7,482; ml: 4,937; javascript: 4,117; makefile: 3,840; awk: 3,535; xml: 914; fortran: 619; cs: 573; ruby: 573
file content (155 lines) | stat: -rw-r--r-- 6,039 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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
// RUN: %empty-directory(%t)
// RUN: %target-build-swift %s -module-name=_Test -import-objc-header %S/Inputs/check_class_for_archiving.h -o %t/a.out
// RUN: %target-codesign %t/a.out
// RUN: %target-run %t/a.out | grep 'check-prefix' > %t/prefix-option
// RUN: %target-run %t/a.out 2>&1 >/dev/null | %FileCheck `cat %t/prefix-option` %s

// REQUIRES: executable_test
// REQUIRES: objc_interop

// This test doesn't use StdlibUnittest because it's primarily concerned with
// checking the presence and absence of output.

import Foundation

// A tricky way to make the FileCheck tests conditional on the OS version.
if #available(SwiftStdlib 5.5, *) {
  print("-check-prefix=CHECK")
} else {
  // Disable the checks for older OSes because of rdar://problem/50504765
  print("-check-prefix=DONT-CHECK")
  // Need at least one check, otherwise FileCheck will complain.
  // DONT-CHECK: {{.}}
}

class SwiftClass {}

func _check(_ label: String, _ cls: AnyObject.Type, _ op: CInt) {
  NSLog("--%@ start", label)
  NSKeyedUnarchiver._swift_checkClassAndWarnForKeyedArchiving(cls, operation: op)
  NSLog("--%@ end", label)
}
func checkArchiving(_ label: String, _ cls: AnyObject.Type) {
  _check(label, cls, 0)
}
func checkUnarchiving(_ label: String, _ cls: AnyObject.Type) {
  _check(label, cls, 1)
}


// CHECK-LABEL: --SwiftClass start
checkArchiving("SwiftClass", SwiftClass.self)
// CHECK-NEXT: --SwiftClass end


private class ArchivedTwice {}

// CHECK-LABEL: --ArchivedTwice1 start
checkArchiving("ArchivedTwice1", ArchivedTwice.self)
// CHECK: Attempting to archive Swift class '_Test.({{.+}}).ArchivedTwice' with {{.+}} runtime name '_TtC{{.+[0-9]+}}ArchivedTwice'
// CHECK: @objc(_TtC{{.+[0-9]+}}ArchivedTwice)

// CHECK-LABEL: --ArchivedTwice2 start
checkArchiving("ArchivedTwice2", ArchivedTwice.self)
// CHECK-NEXT: --ArchivedTwice2 end

private class UnarchivedTwice {}

// CHECK-LABEL: --UnarchivedTwice1 start
checkUnarchiving("UnarchivedTwice1", UnarchivedTwice.self)
// CHECK: Attempting to unarchive Swift class '_Test.({{.+}}).UnarchivedTwice' with {{.+}} runtime name '_TtC{{.+[0-9]+}}UnarchivedTwice'
// CHECK: @objc(_TtC{{.+[0-9]+}}UnarchivedTwice)

// CHECK-LABEL: --UnarchivedTwice2 start
checkUnarchiving("UnarchivedTwice2", UnarchivedTwice.self)
// CHECK-NEXT: --UnarchivedTwice2 end

private class ArchivedThenUnarchived {}

// CHECK-LABEL: --ArchivedThenUnarchived1 start
checkArchiving("ArchivedThenUnarchived1", ArchivedThenUnarchived.self)
// CHECK: Attempting to archive Swift class '_Test.({{.+}}).ArchivedThenUnarchived' with {{.+}} runtime name '_TtC{{.+[0-9]+}}ArchivedThenUnarchived'
// CHECK: @objc(_TtC{{.+[0-9]+}}ArchivedThenUnarchived)

// CHECK-LABEL: --ArchivedThenUnarchived2 start
checkUnarchiving("ArchivedThenUnarchived2", ArchivedThenUnarchived.self)
// CHECK-NEXT: --ArchivedThenUnarchived2 end

private class UnarchivedThenArchived {}

// CHECK-LABEL: --UnarchivedThenArchived1 start
checkUnarchiving("UnarchivedThenArchived1", UnarchivedThenArchived.self)
// CHECK: Attempting to unarchive Swift class '_Test.({{.+}}).UnarchivedThenArchived' with {{.+}} runtime name '_TtC{{.+[0-9]+}}UnarchivedThenArchived'
// CHECK: @objc(_TtC{{.+[0-9]+}}UnarchivedThenArchived)

// CHECK-LABEL: --UnarchivedThenArchived2 start
checkArchiving("UnarchivedThenArchived2", UnarchivedThenArchived.self)
// CHECK-NEXT: --UnarchivedThenArchived2 end

private class Outer {
  class ArchivedTwice {}
  class UnarchivedTwice {}
  class ArchivedThenUnarchived {}
  class UnarchivedThenArchived {}
}

// CHECK-LABEL: --Outer.ArchivedTwice1 start
checkArchiving("Outer.ArchivedTwice1", Outer.ArchivedTwice.self)
// CHECK: Attempting to archive Swift class '_Test.({{.+}}).Outer.ArchivedTwice'
// CHECK: @objc(_TtC{{.+[0-9]+}}ArchivedTwice)

// CHECK-LABEL: --Outer.ArchivedTwice2 start
checkArchiving("Outer.ArchivedTwice2", Outer.ArchivedTwice.self)
// CHECK-NEXT: --Outer.ArchivedTwice2 end

// CHECK-LABEL: --Outer.UnarchivedTwice1 start
checkUnarchiving("Outer.UnarchivedTwice1", Outer.UnarchivedTwice.self)
// CHECK: Attempting to unarchive Swift class '_Test.({{.+}}).Outer.UnarchivedTwice'
// CHECK: @objc(_TtC{{.+[0-9]+}}UnarchivedTwice)

// CHECK-LABEL: --Outer.UnarchivedTwice2 start
checkUnarchiving("Outer.UnarchivedTwice2", Outer.UnarchivedTwice.self)
// CHECK-NEXT: --Outer.UnarchivedTwice2 end

// CHECK-LABEL: --Outer.ArchivedThenUnarchived1 start
checkArchiving("Outer.ArchivedThenUnarchived1", Outer.ArchivedThenUnarchived.self)
// CHECK: Attempting to archive Swift class '_Test.({{.+}}).Outer.ArchivedThenUnarchived'
// CHECK: @objc(_TtC{{.+[0-9]+}}ArchivedThenUnarchived)

// CHECK-LABEL: --Outer.ArchivedThenUnarchived2 start
checkUnarchiving("Outer.ArchivedThenUnarchived2", Outer.ArchivedThenUnarchived.self)
// CHECK-NEXT: --Outer.ArchivedThenUnarchived2 end

// CHECK-LABEL: --Outer.UnarchivedThenArchived1 start
checkUnarchiving("Outer.UnarchivedThenArchived1", Outer.UnarchivedThenArchived.self)
// CHECK: Attempting to unarchive Swift class '_Test.({{.+}}).Outer.UnarchivedThenArchived'
// CHECK: @objc(_TtC{{.+[0-9]+}}UnarchivedThenArchived)

// CHECK-LABEL: --Outer.UnarchivedThenArchived2 start
checkArchiving("Outer.UnarchivedThenArchived2", Outer.UnarchivedThenArchived.self)
// CHECK-NEXT: --Outer.UnarchivedThenArchived2 end


private class 日本語 {}

// CHECK-LABEL: --Japanese1 start
checkArchiving("Japanese1", 日本語.self)
// CHECK: Attempting to archive Swift class '_Test.({{.*}}).日本語'

// CHECK-LABEL: --Japanese2 start
checkArchiving("Japanese2", 日本語.self)
// CHECK-NEXT: --Japanese2 end

func someFunction() {
  class LocalArchived: NSObject {}
  class LocalUnarchived: NSObject {}

  // CHECK-LABEL: --LocalArchived start
  checkArchiving("LocalArchived", LocalArchived.self)
  // CHECK: Attempting to archive Swift class '_Test.({{.+}}).LocalArchived'

  // CHECK-LABEL: --LocalUnarchived start
  checkUnarchiving("LocalUnarchived", LocalUnarchived.self)
  // CHECK: Attempting to unarchive Swift class '_Test.({{.+}}).LocalUnarchived'
}
someFunction()