Skip to content

Commit 222c459

Browse files
authored
[SE-0274] Stage in #filePath (swiftlang#29944)
* Stage in #filePath To give users of #file time to transition, we are first adding #filePath without changing #file’s behavior. This commit makes that change. Fixes <rdar://problem/58586626>. * Correct swiftinterface test line
1 parent 10803c0 commit 222c459

File tree

3 files changed

+14
-17
lines changed

3 files changed

+14
-17
lines changed

include/swift/Option/Options.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -497,7 +497,7 @@ def enable_experimental_differentiable_programming : Flag<["-"], "enable-experim
497497
def enable_experimental_concise_pound_file : Flag<["-"],
498498
"enable-experimental-concise-pound-file">,
499499
Flags<[FrontendOption]>,
500-
HelpText<"Enable experimental concise '#file' identifier and '#filePath' alternative">;
500+
HelpText<"Enable experimental concise '#file' identifier">;
501501

502502
// Diagnostic control options
503503
def suppress_warnings : Flag<["-"], "suppress-warnings">,

lib/Parse/ParseExpr.cpp

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1466,16 +1466,9 @@ ParserResult<Expr> Parser::parseExprPrimary(Diag<> ID, bool isExprBasic) {
14661466
LLVM_FALLTHROUGH;
14671467
}
14681468

1469-
case tok::pound_filePath:
1470-
// Check twice because of fallthrough--this is ugly but temporary.
1471-
if (Tok.is(tok::pound_filePath) && !Context.LangOpts.EnableConcisePoundFile)
1472-
diagnose(Tok.getLoc(), diag::unknown_pound_expr, "filePath");
1473-
// Continue since we actually do know how to handle it. This avoids extra
1474-
// diagnostics.
1475-
LLVM_FALLTHROUGH;
1476-
14771469
case tok::pound_column:
14781470
case tok::pound_file:
1471+
case tok::pound_filePath:
14791472
case tok::pound_function:
14801473
case tok::pound_line:
14811474
case tok::pound_dsohandle: {
Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,19 @@
1-
// Check that we generate the right code with the flag.
2-
// RUN: %target-swift-emit-silgen -enable-experimental-concise-pound-file -module-name Foo %/s | %FileCheck %s
1+
// Check that we generate the right strings.
2+
// RUN: %target-swift-emit-silgen -module-name Foo %/s | %FileCheck %s
33

4-
// Check that we give errors for use of #filePath if concise #file isn't enabled.
5-
// FIXME: Drop if we stop rejecting this.
4+
// Even if concise #file is not available, we now allow you to write #filePath.
5+
// Check that we don't diagnose any errors in this file.
66
// RUN: %target-typecheck-verify-swift -module-name Foo %s
77

8-
// FIXME: Once this feature becomes non-experimental, we should duplicate
8+
// #filePath should appear in swiftinterfaces with this change.
9+
// RUN: %target-swift-frontend-typecheck -module-name Foo -emit-module-interface-path %t.swiftinterface %s
10+
// RUN: %FileCheck -check-prefix SWIFTINTERFACE %s < %t.swiftinterface
11+
12+
// FIXME: Once this feature has been fully staged in, we should duplicate
913
// existing #file tests and delete this file.
1014

1115
func directUse() {
12-
print(#filePath) // expected-error {{use of unknown directive '#filePath'}}
16+
print(#filePath)
1317

1418
// CHECK-LABEL: sil {{.*}} @$s3Foo9directUseyyF
1519
// CHECK: string_literal utf8 "SOURCE_DIR/test/SILGen/magic_identifier_filepath.swift"
@@ -22,5 +26,5 @@ func indirectUse() {
2226
// CHECK: string_literal utf8 "SOURCE_DIR/test/SILGen/magic_identifier_filepath.swift"
2327
}
2428

25-
func functionWithFilePathDefaultArgument(file: String = #filePath) {}
26-
// expected-error@-1 {{use of unknown directive '#filePath'}}
29+
public func functionWithFilePathDefaultArgument(file: String = #filePath) {}
30+
// SWIFTINTERFACE: public func functionWithFilePathDefaultArgument(file: Swift.String = #filePath)

0 commit comments

Comments
 (0)