Skip to content

Commit dfcbb83

Browse files
committed
[New Parser] Don't perform round-trip testing with structural overflows.
If we had a structural overflow, don't perform round-trip testing. The new parser currently fails, and will need to deal with the problem in a more appropriate manner than the existing one, which cuts off lexing entirely.
1 parent c50d166 commit dfcbb83

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

lib/Parse/ParseRequests.cpp

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -201,24 +201,28 @@ SourceFileParsingResult ParseSourceFileRequest::evaluate(Evaluator &evaluator,
201201
auto bufferRange = ctx.SourceMgr.getRangeForBuffer(*bufferID);
202202
unsigned int flags = 0;
203203

204-
if (ctx.LangOpts.hasFeature(Feature::ParserRoundTrip))
204+
if (ctx.LangOpts.hasFeature(Feature::ParserRoundTrip) &&
205+
!parser.L->lexingCutOffOffset()) {
205206
flags |= SCC_RoundTrip;
207+
}
206208

207209
if (!ctx.Diags.hadAnyError() &&
208210
ctx.LangOpts.hasFeature(Feature::ParserValidation))
209211
flags |= SCC_ParseDiagnostics;
210212

211-
if (ctx.LangOpts.hasFeature(Feature::ParserSequenceFolding))
213+
if (ctx.LangOpts.hasFeature(Feature::ParserSequenceFolding) &&
214+
!parser.L->lexingCutOffOffset())
212215
flags |= SCC_FoldSequences;
213216

214-
int roundTripResult =
215-
swift_parser_consistencyCheck(
216-
bufferRange.str().data(), bufferRange.getByteLength(),
217-
SF->getFilename().str().c_str(), flags);
217+
if (flags) {
218+
int roundTripResult = swift_parser_consistencyCheck(
219+
bufferRange.str().data(), bufferRange.getByteLength(),
220+
SF->getFilename().str().c_str(), flags);
218221

219-
// FIXME: Produce an error on round-trip failure.
220-
if (roundTripResult)
221-
abort();
222+
// FIXME: Produce an error on round-trip failure.
223+
if (roundTripResult)
224+
abort();
225+
}
222226
}
223227
#endif
224228

0 commit comments

Comments
 (0)