Skip to content

Commit f6afc00

Browse files
committed
Add a new flag to disable round trip through the new Swift parser
1 parent b6326f5 commit f6afc00

File tree

4 files changed

+18
-9
lines changed

4 files changed

+18
-9
lines changed

include/swift/Option/FrontendOptions.td

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1310,4 +1310,9 @@ def platform_c_calling_convention :
13101310
def platform_c_calling_convention_EQ :
13111311
Joined<["-"], "experimental-platform-c-calling-convention=">,
13121312
Alias<platform_c_calling_convention>;
1313+
1314+
def disable_experimental_parser_round_trip : Flag<["-"],
1315+
"disable-experimental-parser-round-trip">,
1316+
HelpText<"Disable round trip through the new swift parser">;
1317+
13131318
} // end let Flags = [FrontendOption, NoDriverOption, HelpHidden]

lib/Basic/LangOptions.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,6 @@ using namespace swift;
3333

3434
LangOptions::LangOptions() {
3535
// Note: Introduce default-on language options here.
36-
#ifndef NDEBUG
37-
Features.insert(Feature::ParserRoundTrip);
38-
Features.insert(Feature::ParserValidation);
39-
#endif
4036
// Enable any playground options that are enabled by default.
4137
#define PLAYGROUND_OPTION(OptionName, Description, DefaultOn, HighPerfOn) \
4238
if (DefaultOn) \

lib/Frontend/CompilerInvocation.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1402,6 +1402,16 @@ static bool ParseLangArgs(LangOptions &Opts, ArgList &Args,
14021402
}
14031403
}
14041404

1405+
#ifndef NDEBUG
1406+
/// Enable round trip parsing via the new swift parser unless it is disabled
1407+
/// explicitly. The new Swift parser can have mismatches with C++ parser -
1408+
/// rdar://118013482 Use this flag to disable round trip through the new
1409+
/// Swift parser for such cases.
1410+
if (!Args.hasArg(OPT_disable_experimental_parser_round_trip)) {
1411+
Opts.Features.insert(Feature::ParserRoundTrip);
1412+
Opts.Features.insert(Feature::ParserValidation);
1413+
}
1414+
#endif
14051415
return HadError || UnsupportedOS || UnsupportedArch;
14061416
}
14071417

test/Parse/result_depends_on.swift

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %target-typecheck-verify-swift -enable-builtin-module -enable-experimental-feature NonEscapableTypes
1+
// RUN: %target-typecheck-verify-swift -enable-builtin-module -enable-experimental-feature NonEscapableTypes -disable-experimental-parser-round-trip
22
// REQUIRES: asserts
33

44
import Builtin
@@ -19,9 +19,7 @@ func testMultipleTypeSpecifier(x : _resultDependsOn Klass, y : _resultDependsOn
1919
return (Builtin.unsafeCastToNativeObject(x), Builtin.unsafeCastToNativeObject(x))
2020
}
2121

22-
/*
23-
rdar://118125715 (Combining parameter modifiers doesn't work in the new swift parser)
22+
// rdar://118125715 (Combining parameter modifiers doesn't work in the new swift parser)
2423
func testTypeSpecifierBorrowing(x : borrowing _resultDependsOn Klass) -> Builtin.NativeObject {
25-
return Builtin.unsafeCastToNativeObject(x)
24+
return Builtin.unsafeCastToNativeObject(copy x)
2625
}
27-
*/

0 commit comments

Comments
 (0)