forked from swiftlang/swift
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinout2.swift
48 lines (38 loc) · 834 Bytes
/
inout2.swift
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
// RUN: %target-swift-frontend %s -emit-ir -g -o - | %FileCheck %s
// LValues are direct values, too. They are reference types, though.
func markUsed<T>(_ t: T) {}
class Class {
var ivar : Int64
init() { ivar = 1234 }
}
class Other : Class {
var ovar : Int64
override init() {
ovar = 112233
super.init()
ivar = 4321
}
}
struct Struct {
var ivar : Int64
init() { ivar = 4567 }
}
func foo(_ x: inout Class) {
// CHECK: !DILocalVariable(name: "x", arg: 1{{.*}} line: [[@LINE-1]]
markUsed(x.ivar)
x.ivar += 1 // Set breakpoint here
}
func foo(_ x: inout Struct) {
// CHECK: !DILocalVariable(name: "x", arg: 1{{.*}} line: [[@LINE-1]]
markUsed(x.ivar)
x.ivar += 1 // Set breakpoint here
}
func main() {
var c: Class = Other()
var s = Struct()
foo(&c)
foo(&s)
foo(&c)
foo(&s)
}
main()