File: shadowed-arg.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 (22 lines) | stat: -rw-r--r-- 1,052 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
// RUN: %target-swift-frontend %s -parse-as-library -emit-ir -g -o - \
// RUN:   -module-name main | %FileCheck %s
// RUN: %target-swift-frontend %s -parse-as-library -emit-sil \
// RUN:   -Xllvm -sil-print-debuginfo -o - \
// RUN:   -module-name main | %FileCheck %s --check-prefix=SIL

// The variable i and the argument i must be in different scopes or the debugger
// doesn't know which one shadows the other.
public func f(i: Int) {
    let i = [i, i]
    print(i)
}

// CHECK: ![[S1:[0-9]+]] = distinct !DISubprogram(name: "f",
// CHECK: !DILocalVariable(name: "i", arg: 1, scope: ![[S1]],
// CHECK: !DILocalVariable(name: "i", scope: ![[S3:[0-9]+]],
// CHECK: ![[S3]] = distinct !DILexicalBlock(scope: ![[S1]],
// SIL: sil_scope [[S1:[0-9]+]] { {{.*}} parent @$s4main1f1iySi_tF
// SIL: sil_scope [[S2:[0-9]+]] { {{.*}} parent [[S1]] }
// SIL: sil_scope [[S3:[0-9]+]] { {{.*}} parent [[S1]] }
// SIL: debug_value %0 : $Int, let, name "i", argno 1,{{.*}}, scope [[S1]]
// SIL: debug_value {{.*}} : $Array<Int>, let, name "i", {{.*}}, scope [[S3]]