Skip to content

Commit 9cd96a8

Browse files
committed
Skip new parser validation when skipping function bodies
This would otherwise result in false positives, since if the old parser skipping a body with errors would cause a verification failure. Don't perform round trip validation either, since we'll presumbly still hit parsing the full file when not skipping bodies - there's no point running it twice. Resolves rdar://111032175.
1 parent e89de6e commit 9cd96a8

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

lib/Frontend/Frontend.cpp

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

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

0 commit comments

Comments
 (0)