[incrParse] Add coloured output indicating which code got reused

This commit is contained in:
Alex Hoppen
2018-05-03 13:39:12 -07:00
parent 92f8f34d22
commit 8998b27dd4
4 changed files with 26 additions and 7 deletions

View File

@@ -417,9 +417,9 @@ int doIncrementalParse(const char *MainExecutablePath,
SourceLoc End = SourceMgr.getLocForOffset(BufferID, ReuseRange.second);
ReuseLog << "Reused ";
Start.printLineAndColumn(ReuseLog, SourceMgr);
Start.printLineAndColumn(ReuseLog, SourceMgr, BufferID);
ReuseLog << " to ";
End.printLineAndColumn(ReuseLog, SourceMgr);
End.printLineAndColumn(ReuseLog, SourceMgr, BufferID);
ReuseLog << '\n';
}
}
@@ -430,6 +430,21 @@ int doIncrementalParse(const char *MainExecutablePath,
out << *Root;
llvm::outs() << "\n";
auto CurrentOffset = 0;
auto SourceText = SourceMgr.getEntireTextForBuffer(BufferID);
llvm::outs() << "\n\n";
for (auto ReuseRange : Cache.getReusedRanges()) {
llvm::outs().changeColor(llvm::buffer_ostream::Colors::RED);
llvm::outs() << SourceText.substr(CurrentOffset,
ReuseRange.first - CurrentOffset);
llvm::outs().changeColor(llvm::buffer_ostream::Colors::GREEN);
llvm::outs() << SourceText.substr(ReuseRange.first,
ReuseRange.second - ReuseRange.first);
CurrentOffset = ReuseRange.second;
}
return EXIT_SUCCESS;
}