Skip to content

Commit 44a2f67

Browse files
committed
Turn new #file behavior off by default
1 parent 789d38e commit 44a2f67

File tree

4 files changed

+28
-3
lines changed

4 files changed

+28
-3
lines changed

include/swift/Basic/LangOptions.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ namespace swift {
9696

9797
/// If true, '#file' evaluates to the full path rather than a
9898
/// human-readable string.
99-
bool MagicFileIdentifierEvaluatesToPath = false;
99+
bool MagicFileIdentifierEvaluatesToPath = true;
100100

101101
///
102102
/// Support for alternate usage modes

test/PlaygroundTransform/implicit_return_never.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
func f() -> Int {
1515
fatalError()
16-
// CRASH-CHECK: {{[fF]}}atal error: file main.swift (main), line [[@LINE-1]]
16+
// CRASH-CHECK: {{[fF]}}atal error: file {{.*}}/main.swift, line [[@LINE-1]]
1717
}
1818

1919
f()

test/PlaygroundTransform/placeholder.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
func f(crash crash: Bool) -> Int {
1616
if crash {
1717
return <#T#>
18-
// CRASH-CHECK: {{[fF]}}atal error: attempt to evaluate editor placeholder: file main.swift (main), line [[@LINE-1]]
18+
// CRASH-CHECK: {{[fF]}}atal error: attempt to evaluate editor placeholder: file {{.*}}/main.swift, line [[@LINE-1]]
1919
} else {
2020
return 42
2121
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// RUN: %target-swift-emit-silgen -pound-file=path -module-name Foo %s | %FileCheck --check-prefixes=BOTH,PATH %s
2+
// RUN: %target-swift-emit-silgen -pound-file=compact -module-name Foo %s | %FileCheck --check-prefixes=BOTH,COMPACT %s
3+
// RUN: not %target-swift-emit-silgen -pound-file=zyzyx -module-name Foo %s 2>&1 | %FileCheck --check-prefix=ZYZYX %s
4+
5+
// RUN: %target-swift-emit-silgen -pound-file path -module-name Foo %s | %FileCheck --check-prefixes=BOTH,PATH %s
6+
// RUN: %target-swift-emit-silgen -pound-file compact -module-name Foo %s | %FileCheck --check-prefixes=BOTH,COMPACT %s
7+
// RUN: not %target-swift-emit-silgen -pound-file zyzyx -module-name Foo %s 2>&1 | %FileCheck --check-prefix=ZYZYX %s
8+
9+
// RUN: %target-swift-emit-silgen %s -module-name Foo | %FileCheck --check-prefixes=BOTH,COMPACT %s
10+
11+
// ZYZYX: error: invalid value 'zyzyx' in '-pound-file'
12+
13+
func directUse() {
14+
// BOTH-LABEL: sil {{.*}} @$s3Foo9directUseyyF
15+
print(#file)
16+
// PATH: string_literal utf8 "SOURCE_DIR/test/SILGen/magic_identifier_file.swift"
17+
// COMPACT: string_literal utf8 "magic_identifier_file.swift (Foo)"
18+
}
19+
20+
func indirectUse() {
21+
// BOTH-LABEL: sil {{.*}} @$s3Foo11indirectUseyyF
22+
fatalError()
23+
// PATH: string_literal utf8 "SOURCE_DIR/test/SILGen/magic_identifier_file.swift"
24+
// COMPACT: string_literal utf8 "magic_identifier_file.swift (Foo)"
25+
}

0 commit comments

Comments
 (0)