mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Merge pull request #61283 from DougGregor/enable-round-trip-testing
[New parser] Enable round-trip testing of the new parser in +Asserts builds
This commit is contained in:
@@ -31,6 +31,9 @@ using namespace swift;
|
||||
|
||||
LangOptions::LangOptions() {
|
||||
// Note: Introduce default-on language options here.
|
||||
#ifndef NDEBUG
|
||||
Features.insert(Feature::ParserRoundTrip);
|
||||
#endif
|
||||
}
|
||||
|
||||
struct SupportedConditionalValue {
|
||||
|
||||
@@ -201,24 +201,28 @@ SourceFileParsingResult ParseSourceFileRequest::evaluate(Evaluator &evaluator,
|
||||
auto bufferRange = ctx.SourceMgr.getRangeForBuffer(*bufferID);
|
||||
unsigned int flags = 0;
|
||||
|
||||
if (ctx.LangOpts.hasFeature(Feature::ParserRoundTrip))
|
||||
if (ctx.LangOpts.hasFeature(Feature::ParserRoundTrip) &&
|
||||
!parser.L->lexingCutOffOffset()) {
|
||||
flags |= SCC_RoundTrip;
|
||||
}
|
||||
|
||||
if (!ctx.Diags.hadAnyError() &&
|
||||
ctx.LangOpts.hasFeature(Feature::ParserValidation))
|
||||
flags |= SCC_ParseDiagnostics;
|
||||
|
||||
if (ctx.LangOpts.hasFeature(Feature::ParserSequenceFolding))
|
||||
if (ctx.LangOpts.hasFeature(Feature::ParserSequenceFolding) &&
|
||||
!parser.L->lexingCutOffOffset())
|
||||
flags |= SCC_FoldSequences;
|
||||
|
||||
int roundTripResult =
|
||||
swift_parser_consistencyCheck(
|
||||
bufferRange.str().data(), bufferRange.getByteLength(),
|
||||
SF->getFilename().str().c_str(), flags);
|
||||
if (flags) {
|
||||
int roundTripResult = swift_parser_consistencyCheck(
|
||||
bufferRange.str().data(), bufferRange.getByteLength(),
|
||||
SF->getFilename().str().c_str(), flags);
|
||||
|
||||
// FIXME: Produce an error on round-trip failure.
|
||||
if (roundTripResult)
|
||||
abort();
|
||||
// FIXME: Produce an error on round-trip failure.
|
||||
if (roundTripResult)
|
||||
abort();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user