Skip to content

Commit a5607cc

Browse files
authored
Merge pull request #67352 from bnbarham/disable-new-validation-when-skipping
Skip new parser validation when skipping function bodies
2 parents e495eed + 392f98c commit a5607cc

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
@@ -1540,10 +1540,22 @@ CompilerInstance::getSourceFileParsingOptions(bool forPrimary) const {
15401540
opts |= ParsingFlags::SuppressWarnings;
15411541
}
15421542

1543-
// Turn off round-trip checking for secondary files, and for dependency
1544-
// scanning and IDE inspection.
1543+
// Turn off new parser round-trip and diagnostics checking for
1544+
// - secondary files
1545+
// - Only want to verify on primary files, no point checking more than
1546+
// once
1547+
// - IDE inspection
1548+
// - We don't want to pay the cost of verification for simple IDE
1549+
// functionality (eg. completion and cursor info)
1550+
// - dependency scanning
1551+
// - Same as IDE inspection, this is meant to be a very fast operation.
1552+
// Don't slow it down
1553+
// - skipped function bodies
1554+
// - Swift parser doesn't support function body skipping yet, so this
1555+
// would result in verification failures when bodies have errors
15451556
if (!isEffectivelyPrimary || SourceMgr.hasIDEInspectionTargetBuffer() ||
1546-
frontendOpts.RequestedAction == ActionType::ScanDependencies) {
1557+
frontendOpts.RequestedAction == ActionType::ScanDependencies ||
1558+
typeOpts.SkipFunctionBodies != FunctionBodySkipping::None) {
15471559
opts -= ParsingFlags::RoundTrip;
15481560
opts -= ParsingFlags::ValidateNewParserDiagnostics;
15491561
}
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 precede '->'}}
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)