[gardening] convert ByteBasedSourceRange to CharSourceRange rather than SourceRange

The only client of the 'toSourceRange' method immediately constructs a
CharSourceRange from it, and ByteBasedSourceRange's EndLoc isn't the start of
the last token in the range (as SourceRange expects).
This commit is contained in:
Nathan Hawes
2018-10-11 14:36:09 -07:00
parent efa2c5475d
commit 9003d83ffe

View File

@@ -246,10 +246,10 @@ struct ByteBasedSourceRange {
bool empty() { return Start == End; }
SourceRange toSourceRange(SourceManager &SourceMgr, unsigned BufferID) {
CharSourceRange toCharSourceRange(SourceManager &SourceMgr, unsigned BufferID) {
auto StartLoc = SourceMgr.getLocForOffset(BufferID, Start);
auto EndLoc = SourceMgr.getLocForOffset(BufferID, End);
return SourceRange(StartLoc, EndLoc);
return CharSourceRange(SourceMgr, StartLoc, EndLoc);
}
};
@@ -538,12 +538,11 @@ bool verifyReusedRegions(ByteBasedSourceRangeSet ExpectedReparseRegions,
bool NoUnexpectedParse = true;
for (auto ReparseRegion : UnexpectedReparseRegions.Ranges) {
auto ReparseRange = ReparseRegion.toSourceRange(SourceMgr, BufferID);
auto ReparseRange = ReparseRegion.toCharSourceRange(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();
auto RangeStr = ReparseRange.str();
llvm::Regex WhitespaceOnlyRegex("^[ \t\r\n]*$");
if (WhitespaceOnlyRegex.match(RangeStr)) {
continue;