Skip to content

Commit 63ec1cf

Browse files
committed
Introduce a separate #filePath, remove -pound-file
This makes the path behavior more first-class. The feature is now hidden behind an experimental flag, -enable-experimental-concise-pound-file.
1 parent 2acaf38 commit 63ec1cf

27 files changed

+120
-42
lines changed

include/swift/AST/DefaultArgumentKind.h

+2
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ enum class DefaultArgumentKind : uint8_t {
3838
Inherited,
3939
/// The #file default argument, which is expanded at the call site.
4040
File,
41+
/// The #filePath default argument, which is expanded at the call site.
42+
FilePath,
4143
/// The #line default argument, which is expanded at the call site.
4244
Line,
4345
/// The #column default argument, which is expanded at the call site.

include/swift/AST/Expr.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -1040,7 +1040,7 @@ class InterpolatedStringLiteralExpr : public LiteralExpr {
10401040
class MagicIdentifierLiteralExpr : public LiteralExpr {
10411041
public:
10421042
enum Kind : unsigned {
1043-
File, Line, Column, Function, DSOHandle
1043+
File, FilePath, Line, Column, Function, DSOHandle
10441044
};
10451045
private:
10461046
SourceLoc Loc;
@@ -1067,6 +1067,7 @@ class MagicIdentifierLiteralExpr : public LiteralExpr {
10671067
bool isString() const {
10681068
switch (getKind()) {
10691069
case File:
1070+
case FilePath:
10701071
case Function:
10711072
return true;
10721073
case Line:

include/swift/Basic/LangOptions.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,9 @@ namespace swift {
9494
/// when using RequireExplicitAvailability.
9595
std::string RequireExplicitAvailabilityTarget;
9696

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

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

include/swift/Option/Options.td

+5-8
Original file line numberDiff line numberDiff line change
@@ -267,14 +267,6 @@ def output_file_map_EQ : Joined<["-"], "output-file-map=">,
267267
Flags<[NoInteractiveOption, ArgumentIsPath]>,
268268
Alias<output_file_map>;
269269

270-
def pound_file : Separate<["-"], "pound-file">,
271-
Flags<[FrontendOption]>,
272-
HelpText<"Specifies whether '#file' evaluates to a full path or a compact human-readable string">,
273-
MetaVarName<"compact|path">;
274-
def pound_file_EQ : Joined<["-"], "pound-file=">,
275-
Flags<[FrontendOption]>,
276-
Alias<pound_file>;
277-
278270
def save_temps : Flag<["-"], "save-temps">,
279271
Flags<[NoInteractiveOption,DoesNotAffectIncrementalBuild]>,
280272
HelpText<"Save intermediate compilation results">;
@@ -462,6 +454,11 @@ def enable_experimental_differentiable_programming : Flag<["-"], "enable-experim
462454
Flags<[FrontendOption]>,
463455
HelpText<"Enable experimental differentiable programming features">;
464456

457+
def enable_experimental_concise_pound_file : Flag<["-"],
458+
"enable-experimental-concise-pound-file">,
459+
Flags<[FrontendOption]>,
460+
HelpText<"Enable experimental concise '#file' identifier and '#filePath' alternative">;
461+
465462
// Diagnostic control options
466463
def suppress_warnings : Flag<["-"], "suppress-warnings">,
467464
Flags<[FrontendOption]>,

lib/AST/ASTDumper.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,7 @@ static StringRef getDefaultArgumentKindString(DefaultArgumentKind value) {
300300
case DefaultArgumentKind::Column: return "#column";
301301
case DefaultArgumentKind::DSOHandle: return "#dsohandle";
302302
case DefaultArgumentKind::File: return "#file";
303+
case DefaultArgumentKind::FilePath: return "#filePath";
303304
case DefaultArgumentKind::Function: return "#function";
304305
case DefaultArgumentKind::Inherited: return "inherited";
305306
case DefaultArgumentKind::Line: return "#line";
@@ -316,6 +317,7 @@ static StringRef
316317
getMagicIdentifierLiteralExprKindString(MagicIdentifierLiteralExpr::Kind value) {
317318
switch (value) {
318319
case MagicIdentifierLiteralExpr::File: return "#file";
320+
case MagicIdentifierLiteralExpr::FilePath: return "#filePath";
319321
case MagicIdentifierLiteralExpr::Function: return "#function";
320322
case MagicIdentifierLiteralExpr::Line: return "#line";
321323
case MagicIdentifierLiteralExpr::Column: return "#column";

lib/AST/Decl.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -6083,6 +6083,7 @@ bool ParamDecl::hasDefaultExpr() const {
60836083
return false;
60846084
case DefaultArgumentKind::Normal:
60856085
case DefaultArgumentKind::File:
6086+
case DefaultArgumentKind::FilePath:
60866087
case DefaultArgumentKind::Line:
60876088
case DefaultArgumentKind::Column:
60886089
case DefaultArgumentKind::Function:
@@ -6105,6 +6106,7 @@ bool ParamDecl::hasCallerSideDefaultExpr() const {
61056106
case DefaultArgumentKind::Normal:
61066107
return false;
61076108
case DefaultArgumentKind::File:
6109+
case DefaultArgumentKind::FilePath:
61086110
case DefaultArgumentKind::Line:
61096111
case DefaultArgumentKind::Column:
61106112
case DefaultArgumentKind::Function:
@@ -6414,6 +6416,7 @@ ParamDecl::getDefaultValueStringRepresentation(
64146416
}
64156417
case DefaultArgumentKind::Inherited: return "super";
64166418
case DefaultArgumentKind::File: return "#file";
6419+
case DefaultArgumentKind::FilePath: return "#filePath";
64176420
case DefaultArgumentKind::Line: return "#line";
64186421
case DefaultArgumentKind::Column: return "#column";
64196422
case DefaultArgumentKind::Function: return "#function";

lib/Driver/ToolChains.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,8 @@ static void addCommonFrontendArgs(const ToolChain &TC, const OutputInfo &OI,
238238
inputArgs.AddLastArg(arguments, options::OPT_enable_astscope_lookup);
239239
inputArgs.AddLastArg(arguments, options::OPT_disable_astscope_lookup);
240240
inputArgs.AddLastArg(arguments, options::OPT_disable_parser_lookup);
241-
inputArgs.AddLastArg(arguments, options::OPT_pound_file);
241+
inputArgs.AddLastArg(arguments,
242+
options::OPT_enable_experimental_concise_pound_file);
242243

243244
// Pass on any build config options
244245
inputArgs.AddAllArgs(arguments, options::OPT_D);

lib/Frontend/CompilerInvocation.cpp

+2-10
Original file line numberDiff line numberDiff line change
@@ -453,16 +453,8 @@ static bool ParseLangArgs(LangOptions &Opts, ArgList &Args,
453453
Opts.OptimizationRemarkMissedPattern =
454454
generateOptimizationRemarkRegex(Diags, Args, A);
455455

456-
if (Arg *A = Args.getLastArg(OPT_pound_file)) {
457-
StringRef value = A->getValue();
458-
if (value == "path")
459-
Opts.MagicFileIdentifierEvaluatesToPath = true;
460-
else if (value == "compact")
461-
Opts.MagicFileIdentifierEvaluatesToPath = false;
462-
else
463-
Diags.diagnose(SourceLoc(), diag::error_invalid_arg_value,
464-
A->getSpelling(), value);
465-
}
456+
Opts.EnableConcisePoundFile =
457+
Args.hasArg(OPT_enable_experimental_concise_pound_file);
466458

467459
llvm::Triple Target = Opts.Target;
468460
StringRef TargetArg;

lib/IDE/CodeCompletion.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -2244,6 +2244,7 @@ class CompletionLookup final : public swift::VisibleDeclConsumer {
22442244
return !includeDefaultArgs;
22452245

22462246
case DefaultArgumentKind::File:
2247+
case DefaultArgumentKind::FilePath:
22472248
case DefaultArgumentKind::Line:
22482249
case DefaultArgumentKind::Column:
22492250
case DefaultArgumentKind::Function:
@@ -3653,6 +3654,10 @@ class CompletionLookup final : public swift::VisibleDeclConsumer {
36533654
CodeCompletionLiteralKind::StringLiteral, "String");
36543655
addFromProto("#file", CodeCompletionKeywordKind::pound_file,
36553656
CodeCompletionLiteralKind::StringLiteral, "String");
3657+
if (Ctx.LangOpts.EnableConcisePoundFile) {
3658+
addFromProto("#filePath", CodeCompletionKeywordKind::pound_file,
3659+
CodeCompletionLiteralKind::StringLiteral, "String");
3660+
}
36563661
addFromProto("#line", CodeCompletionKeywordKind::pound_line,
36573662
CodeCompletionLiteralKind::IntegerLiteral, "Int");
36583663
addFromProto("#column", CodeCompletionKeywordKind::pound_column,

lib/Parse/ParseExpr.cpp

+12
Original file line numberDiff line numberDiff line change
@@ -1014,6 +1014,8 @@ getMagicIdentifierLiteralKind(tok Kind) {
10141014
case tok::kw___FILE__:
10151015
case tok::pound_file:
10161016
return MagicIdentifierLiteralExpr::Kind::File;
1017+
case tok::pound_filePath:
1018+
return MagicIdentifierLiteralExpr::Kind::FilePath;
10171019
case tok::kw___FUNCTION__:
10181020
case tok::pound_function:
10191021
return MagicIdentifierLiteralExpr::Kind::Function;
@@ -1446,6 +1448,15 @@ ParserResult<Expr> Parser::parseExprPrimary(Diag<> ID, bool isExprBasic) {
14461448
.fixItReplace(Tok.getLoc(), replacement);
14471449
LLVM_FALLTHROUGH;
14481450
}
1451+
1452+
case tok::pound_filePath:
1453+
// Check twice because of fallthrough--this is ugly but temporary.
1454+
if (Tok.is(tok::pound_filePath) && !Context.LangOpts.EnableConcisePoundFile)
1455+
diagnose(Tok.getLoc(), diag::unknown_pound_expr, "filePath");
1456+
// Continue since we actually do know how to handle it. This avoids extra
1457+
// diagnostics.
1458+
LLVM_FALLTHROUGH;
1459+
14491460
case tok::pound_column:
14501461
case tok::pound_file:
14511462
case tok::pound_function:
@@ -1455,6 +1466,7 @@ ParserResult<Expr> Parser::parseExprPrimary(Diag<> ID, bool isExprBasic) {
14551466
switch (Tok.getKind()) {
14561467
case tok::pound_column: SKind = SyntaxKind::PoundColumnExpr; break;
14571468
case tok::pound_file: SKind = SyntaxKind::PoundFileExpr; break;
1469+
case tok::pound_filePath: SKind = SyntaxKind::PoundFilePathExpr; break;
14581470
case tok::pound_function: SKind = SyntaxKind::PoundFunctionExpr; break;
14591471
// FIXME: #line was renamed to #sourceLocation
14601472
case tok::pound_line: SKind = SyntaxKind::PoundLineExpr; break;

lib/Parse/ParsePattern.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ static DefaultArgumentKind getDefaultArgKind(Expr *init) {
4848
return DefaultArgumentKind::Column;
4949
case MagicIdentifierLiteralExpr::File:
5050
return DefaultArgumentKind::File;
51+
case MagicIdentifierLiteralExpr::FilePath:
52+
return DefaultArgumentKind::FilePath;
5153
case MagicIdentifierLiteralExpr::Line:
5254
return DefaultArgumentKind::Line;
5355
case MagicIdentifierLiteralExpr::Function:

lib/SILGen/SILGen.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -1090,6 +1090,7 @@ void SILGenModule::emitDefaultArgGenerator(SILDeclRef constant,
10901090
case DefaultArgumentKind::Inherited:
10911091
case DefaultArgumentKind::Column:
10921092
case DefaultArgumentKind::File:
1093+
case DefaultArgumentKind::FilePath:
10931094
case DefaultArgumentKind::Line:
10941095
case DefaultArgumentKind::Function:
10951096
case DefaultArgumentKind::DSOHandle:

lib/SILGen/SILGenApply.cpp

+22-5
Original file line numberDiff line numberDiff line change
@@ -4876,14 +4876,20 @@ getMagicFunctionString(SILGenFunction &SGF) {
48764876
return SGF.MagicFunctionString;
48774877
}
48784878

4879-
static std::string getMagicFileString(SILGenFunction &SGF, SourceLoc loc) {
4879+
static StringRef
4880+
getMagicFilePathString(SILGenFunction &SGF, SourceLoc loc) {
48804881
if (!loc.isValid())
48814882
return "";
48824883

4883-
auto path = SGF.getASTContext().SourceMgr.getDisplayNameForLoc(loc);
4884-
if (SGF.getASTContext().LangOpts.MagicFileIdentifierEvaluatesToPath)
4885-
return path;
4884+
return SGF.getASTContext().SourceMgr.getDisplayNameForLoc(loc);
4885+
}
4886+
4887+
static std::string
4888+
getConciseMagicFileString(SILGenFunction &SGF, SourceLoc loc) {
4889+
if (!loc.isValid())
4890+
return "";
48864891

4892+
auto path = getMagicFilePathString(SGF, loc);
48874893
auto value = llvm::sys::path::filename(path).str();
48884894
value += " (";
48894895
value += SGF.getModule().getSwiftModule()->getNameStr();
@@ -5146,7 +5152,18 @@ RValue SILGenFunction::emitLiteral(LiteralExpr *literal, SGFContext C) {
51465152
auto magicLiteral = cast<MagicIdentifierLiteralExpr>(literal);
51475153
switch (magicLiteral->getKind()) {
51485154
case MagicIdentifierLiteralExpr::File: {
5149-
std::string value = getMagicFileString(*this, loc);
5155+
std::string value = getASTContext().LangOpts.EnableConcisePoundFile
5156+
? getConciseMagicFileString(*this, loc)
5157+
: getMagicFilePathString(*this, loc).str();
5158+
builtinLiteralArgs = emitStringLiteral(*this, literal, value, C,
5159+
magicLiteral->getStringEncoding());
5160+
builtinInit = magicLiteral->getBuiltinInitializer();
5161+
init = magicLiteral->getInitializer();
5162+
break;
5163+
}
5164+
5165+
case MagicIdentifierLiteralExpr::FilePath: {
5166+
StringRef value = getMagicFilePathString(*this, loc);
51505167
builtinLiteralArgs = emitStringLiteral(*this, literal, value, C,
51515168
magicLiteral->getStringEncoding());
51525169
builtinInit = magicLiteral->getBuiltinInitializer();

lib/SILGen/SILGenExpr.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -3681,6 +3681,7 @@ RValue RValueEmitter::
36813681
visitMagicIdentifierLiteralExpr(MagicIdentifierLiteralExpr *E, SGFContext C) {
36823682
switch (E->getKind()) {
36833683
case MagicIdentifierLiteralExpr::File:
3684+
case MagicIdentifierLiteralExpr::FilePath:
36843685
case MagicIdentifierLiteralExpr::Function:
36853686
case MagicIdentifierLiteralExpr::Line:
36863687
case MagicIdentifierLiteralExpr::Column:

lib/Sema/CSApply.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -2157,6 +2157,7 @@ namespace {
21572157
Expr *visitMagicIdentifierLiteralExpr(MagicIdentifierLiteralExpr *expr) {
21582158
switch (expr->getKind()) {
21592159
case MagicIdentifierLiteralExpr::File:
2160+
case MagicIdentifierLiteralExpr::FilePath:
21602161
case MagicIdentifierLiteralExpr::Function:
21612162
return handleStringLiteralExpr(expr);
21622163

lib/Sema/CSGen.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -1243,6 +1243,7 @@ namespace {
12431243
switch (expr->getKind()) {
12441244
case MagicIdentifierLiteralExpr::Column:
12451245
case MagicIdentifierLiteralExpr::File:
1246+
case MagicIdentifierLiteralExpr::FilePath:
12461247
case MagicIdentifierLiteralExpr::Function:
12471248
case MagicIdentifierLiteralExpr::Line:
12481249
return visitLiteralExpr(expr);

lib/Sema/TypeCheckExpr.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -730,6 +730,11 @@ static Expr *synthesizeCallerSideDefault(const ParamDecl *param,
730730
MagicIdentifierLiteralExpr(MagicIdentifierLiteralExpr::File, loc,
731731
/*implicit=*/true);
732732

733+
case DefaultArgumentKind::FilePath:
734+
return new (ctx)
735+
MagicIdentifierLiteralExpr(MagicIdentifierLiteralExpr::FilePath, loc,
736+
/*implicit=*/true);
737+
733738
case DefaultArgumentKind::Line:
734739
return new (ctx)
735740
MagicIdentifierLiteralExpr(MagicIdentifierLiteralExpr::Line, loc,

lib/Sema/TypeCheckStmt.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -1531,6 +1531,7 @@ static void diagnoseIgnoredLiteral(ASTContext &Ctx, LiteralExpr *LE) {
15311531
case ExprKind::MagicIdentifierLiteral:
15321532
switch (cast<MagicIdentifierLiteralExpr>(LE)->getKind()) {
15331533
case MagicIdentifierLiteralExpr::Kind::File: return "#file";
1534+
case MagicIdentifierLiteralExpr::Kind::FilePath: return "#filePath";
15341535
case MagicIdentifierLiteralExpr::Kind::Line: return "#line";
15351536
case MagicIdentifierLiteralExpr::Kind::Column: return "#column";
15361537
case MagicIdentifierLiteralExpr::Kind::Function: return "#function";

lib/Sema/TypeChecker.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ ProtocolDecl *TypeChecker::getLiteralProtocol(ASTContext &Context, Expr *expr) {
131131
if (auto E = dyn_cast<MagicIdentifierLiteralExpr>(expr)) {
132132
switch (E->getKind()) {
133133
case MagicIdentifierLiteralExpr::File:
134+
case MagicIdentifierLiteralExpr::FilePath:
134135
case MagicIdentifierLiteralExpr::Function:
135136
return TypeChecker::getProtocol(
136137
Context, expr->getLoc(),

lib/Serialization/Deserialization.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,8 @@ getActualDefaultArgKind(uint8_t raw) {
207207
return swift::DefaultArgumentKind::Column;
208208
case serialization::DefaultArgumentKind::File:
209209
return swift::DefaultArgumentKind::File;
210+
case serialization::DefaultArgumentKind::FilePath:
211+
return swift::DefaultArgumentKind::FilePath;
210212
case serialization::DefaultArgumentKind::Line:
211213
return swift::DefaultArgumentKind::Line;
212214
case serialization::DefaultArgumentKind::Function:

lib/Serialization/ModuleFormat.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ const uint16_t SWIFTMODULE_VERSION_MAJOR = 0;
5252
/// describe what change you made. The content of this comment isn't important;
5353
/// it just ensures a conflict if two people change the module format.
5454
/// Don't worry about adhering to the 80-column limit for this line.
55-
const uint16_t SWIFTMODULE_VERSION_MINOR = 526; // @_dynamicReplacement adjustments
55+
const uint16_t SWIFTMODULE_VERSION_MINOR = 527; // #filePath
5656

5757
/// A standard hash seed used for all string hashes in a serialized module.
5858
///
@@ -437,6 +437,7 @@ enum class DefaultArgumentKind : uint8_t {
437437
None = 0,
438438
Normal,
439439
File,
440+
FilePath,
440441
Line,
441442
Column,
442443
Function,

lib/Serialization/Serialization.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -1065,6 +1065,7 @@ static uint8_t getRawStableDefaultArgumentKind(swift::DefaultArgumentKind kind)
10651065
CASE(Inherited)
10661066
CASE(Column)
10671067
CASE(File)
1068+
CASE(FilePath)
10681069
CASE(Line)
10691070
CASE(Function)
10701071
CASE(DSOHandle)
+8-14
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,19 @@
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
1+
// RUN: %target-swift-emit-silgen -module-name Foo %s | %FileCheck --check-prefixes=BOTH,ABSOLUTE %s
2+
// RUN: %target-swift-emit-silgen -enable-experimental-concise-pound-file -DNEEDS_CONCISE -module-name Foo %s | %FileCheck --check-prefixes=BOTH,CONCISE %s
43

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,PATH %s
10-
11-
// ZYZYX: error: invalid value 'zyzyx' in '-pound-file'
4+
// FIXME: Once this feature becomes non-experimental, we should update existing
5+
// tests and delete this file.
126

137
func directUse() {
148
// BOTH-LABEL: sil {{.*}} @$s3Foo9directUseyyF
159
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)"
10+
// ABSOLUTE: string_literal utf8 "SOURCE_DIR/test/SILGen/magic_identifier_file.swift"
11+
// CONCISE: string_literal utf8 "magic_identifier_file.swift (Foo)"
1812
}
1913

2014
func indirectUse() {
2115
// BOTH-LABEL: sil {{.*}} @$s3Foo11indirectUseyyF
2216
fatalError()
23-
// PATH: string_literal utf8 "SOURCE_DIR/test/SILGen/magic_identifier_file.swift"
24-
// COMPACT: string_literal utf8 "magic_identifier_file.swift (Foo)"
17+
// ABSOLUTE: string_literal utf8 "SOURCE_DIR/test/SILGen/magic_identifier_file.swift"
18+
// CONCISE: string_literal utf8 "magic_identifier_file.swift (Foo)"
2519
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
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
3+
4+
// Check that we give errors for use of #filePath if concise #file isn't enabled.
5+
// FIXME: Drop if we stop rejecting this.
6+
// RUN: %target-typecheck-verify-swift -module-name Foo %s
7+
8+
// FIXME: Once this feature becomes non-experimental, we should duplicate
9+
// existing #file tests and delete this file.
10+
11+
func directUse() {
12+
print(#filePath) // expected-error {{use of unknown directive '#filePath'}}
13+
14+
// CHECK-LABEL: sil {{.*}} @$s3Foo9directUseyyF
15+
// CHECK: string_literal utf8 "SOURCE_DIR/test/SILGen/magic_identifier_filepath.swift"
16+
}
17+
18+
func indirectUse() {
19+
functionWithFilePathDefaultArgument()
20+
21+
// CHECK-LABEL: sil {{.*}} @$s3Foo11indirectUseyyF
22+
// CHECK: string_literal utf8 "SOURCE_DIR/test/SILGen/magic_identifier_filepath.swift"
23+
}
24+
25+
func functionWithFilePathDefaultArgument(file: String = #filePath) {}
26+
// expected-error@-1 {{use of unknown directive '#filePath'}}

0 commit comments

Comments
 (0)