[incrParse] Allow whitespaces to be reparsed in test

This greatly improves the ergonomics of writing tests and outweighs the
ability to test which whitespaces get parsed since their parsing
overhead should be minimal.
This commit is contained in:
Alex Hoppen
2018-05-08 09:44:13 -07:00
parent 9bdc54a29c
commit c31a880a47
2 changed files with 13 additions and 3 deletions

View File

@@ -509,9 +509,19 @@ bool verifyReusedRegions(ByteBasedSourceRangeSet ExpectedReparseRegions,
bool NoUnexpectedParse = true;
for (auto ReparseRegion : UnexpectedReparseRegions.Ranges) {
NoUnexpectedParse = false;
auto ReparseRange = ReparseRegion.toSourceRange(SourceMgr, BufferID);
// To improve the ergonomics when writing tests we do not want to complain
// about reparsed whitespaces.
auto RangeStr =
CharSourceRange(SourceMgr, ReparseRange.Start, ReparseRange.End).str();
llvm::Regex WhitespaceOnlyRegex("^\\s*$", llvm::Regex::Newline);
if (WhitespaceOnlyRegex.match(RangeStr)) {
continue;
}
NoUnexpectedParse = false;
llvm::errs() << "\nERROR: Unexpectedly reparsed following region:\n";
ReparseRange.print(llvm::errs(), SourceMgr);
}