Skip to content

Commit 9c3928c

Browse files
authored
Merge pull request #67492 from bnbarham/cherry-disable-new-validation-when-skipping
[5.9] Skip new parser validation when skipping function bodies
2 parents fbb061e + 20160d7 commit 9c3928c

File tree

3 files changed

+35
-7
lines changed

3 files changed

+35
-7
lines changed

lib/Frontend/Frontend.cpp

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1405,10 +1405,22 @@ CompilerInstance::getSourceFileParsingOptions(bool forPrimary) const {
14051405
opts |= ParsingFlags::SuppressWarnings;
14061406
}
14071407

1408-
// Turn off round-trip checking for secondary files, and for dependency
1409-
// scanning and IDE inspection.
1408+
// Turn off new parser round-trip and diagnostics checking for
1409+
// - secondary files
1410+
// - Only want to verify on primary files, no point checking more than
1411+
// once
1412+
// - IDE inspection
1413+
// - We don't want to pay the cost of verification for simple IDE
1414+
// functionality (eg. completion and cursor info)
1415+
// - dependency scanning
1416+
// - Same as IDE inspection, this is meant to be a very fast operation.
1417+
// Don't slow it down
1418+
// - skipped function bodies
1419+
// - Swift parser doesn't support function body skipping yet, so this
1420+
// would result in verification failures when bodies have errors
14101421
if (!isEffectivelyPrimary || SourceMgr.hasIDEInspectionTargetBuffer() ||
1411-
frontendOpts.RequestedAction == ActionType::ScanDependencies) {
1422+
frontendOpts.RequestedAction == ActionType::ScanDependencies ||
1423+
typeOpts.SkipFunctionBodies != FunctionBodySkipping::None) {
14121424
opts -= ParsingFlags::RoundTrip;
14131425
opts -= ParsingFlags::ValidateNewParserDiagnostics;
14141426
}
Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
// RUN: %target-typecheck-verify-swift -enable-experimental-feature ParserDiagnostics
2-
3-
// FIXME: Swift parser is not enabled on Linux CI yet.
4-
// REQUIRES: OS=macosx
1+
// REQUIRES: swift_swift_parser
52
// REQUIRES: asserts
63

4+
// RUN: %target-typecheck-verify-swift -enable-experimental-feature ParserDiagnostics
5+
76
_ = [(Int) -> async throws Int]()
87
// expected-error@-1{{'async throws' must preceed '->'}}
98
// expected-note@-2{{move 'async throws' in front of '->'}}{{15-21=}} {{21-28=}} {{20-21= }} {{12-12=async }} {{12-12=throws }}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// REQUIRES: swift_swift_parser
2+
// REQUIRES: asserts
3+
4+
// Checks that skipping function bodies doesn't cause the new parser validation
5+
// to fail. This can currently be the case because the new parser doesn't
6+
// support skipping, causing validation fail as it generates diagnostics when
7+
// the C++ parser would not.
8+
9+
// RUN: %target-typecheck-verify-swift -enable-experimental-feature ParserValidation
10+
// RUN: %target-swift-frontend -typecheck %s -enable-experimental-feature ParserValidation -experimental-skip-all-function-bodies
11+
12+
func bad() {
13+
_ = [(Int) -> async throws Int]()
14+
// expected-error@-1{{'throws' may only occur before '->'}}
15+
// expected-error@-2{{'async' may only occur before '->'}}
16+
}
17+

0 commit comments

Comments
 (0)