Skip to content

Commit 2af7c10

Browse files
committed
DebugInfo: deal with absolute path on Windows
Windows absolute paths are either UNC paths (begin with \\) or are rooted with a drive letter. Unfortunately, we cannot conditionalise the path itself on the OS type. On Unices // indicates the alternate root path as per POSIX. However, Linux does not implement this and // is treated as /. Use this to create a path that appears to be absolute on all the targets.
1 parent 8420a00 commit 2af7c10

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

test/DebugInfo/line-directive.swift

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@ func f() {
88
markUsed("Test")
99
#sourceLocation(file: "abc.swift", line: 142)
1010
markUsed("abc again")
11-
#sourceLocation(file: "/absolute/path/def.swift", line: 142)
11+
// NOTE: we use `//absolute/path` here as this is an absolute path on the
12+
// alternate root. However, it is also a path which is a UNC path on Windows.
13+
// This allows the path to be absolute across both environments.
14+
#sourceLocation(file: "//absolute/path/def.swift", line: 142)
1215
markUsed("jump directly to def")
1316
}
1417

@@ -19,7 +22,7 @@ func f() {
1922
// CHECK: .loc [[ABC]] 42
2023
// CHECK: .loc [[MAIN]] 8
2124
// CHECK: .loc [[ABC]] 142
22-
// CHECK: .file [[DEF:.*]] "/absolute/path/def.swift"
25+
// CHECK: .file [[DEF:.*]] "//absolute/path{{/|\\\\}}def.swift"
2326
// CHECK: .loc [[DEF]] 142
2427
// CHECK: .asciz "{{.*}}test/DebugInfo"
2528

@@ -32,6 +35,6 @@ func f() {
3235
// VFS: .loc [[ABC]] 42
3336
// VFS: .loc [[MAIN]] 8
3437
// VFS: .loc [[ABC]] 142
35-
// VFS: .file [[DEF:.*]] "/absolute/path/def.swift"
38+
// VFS: .file [[DEF:.*]] "//absolute/path{{/|\\\\}}def.swift"
3639
// VFS: .loc [[DEF]] 142
3740
// VFS: .asciz "{{.*}}test/DebugInfo"

0 commit comments

Comments
 (0)