[Gardening] Do not store start/end line in SingleRawComment

The start and end lines were only used while constructing the comments,
so move the line tracking into that method instead of storing it in each
comment.
This commit is contained in:
Ben Barham
2021-04-13 11:01:50 +10:00
parent b15f77db28
commit 52de30ce1f
6 changed files with 60 additions and 77 deletions

View File

@@ -879,10 +879,10 @@ SourceFile::getBasicLocsForDecl(const Decl *D) const {
Result.SourceFilePath = SM.getDisplayNameForLoc(D->getLoc());
for (const auto &SRC : D->getRawComment(/*SerializedOK*/false).Comments) {
Result.DocRanges.push_back(std::make_pair(
SourcePosition { SRC.StartLine, SRC.StartColumn },
SRC.Range.getByteLength())
);
auto LineAndCol = SM.getLineAndColumnInBuffer(SRC.Range.getStart());
Result.DocRanges.push_back(
std::make_pair(SourcePosition{LineAndCol.first, LineAndCol.second},
SRC.Range.getByteLength()));
}
auto setLineColumn = [&SM](SourcePosition &Home, SourceLoc Loc) {