Simplify the implementation of SourceManager::decompose() and its client

Swift SVN r7119
This commit is contained in:
Dmitri Hrybenko
2013-08-10 01:32:42 +00:00
parent 0761a2ebd7
commit 09837a1b88
2 changed files with 25 additions and 46 deletions

View File

@@ -45,14 +45,8 @@ DecomposedLoc SourceManager::decompose(SourceLoc Loc) const {
DecomposedLoc Result;
Result.Buffer = LLVMSourceMgr.getMemoryBuffer(BufferID);
Result.Line = LLVMSourceMgr.FindLineNumber(Loc.Value, BufferID);
const char *BufferStart = Result.Buffer->getBufferStart();
const char *LineStart = Loc.Value.getPointer();
while (LineStart != BufferStart &&
LineStart[-1] != '\n' && LineStart[-1] != '\r')
--LineStart;
Result.Column = Loc.Value.getPointer() - LineStart;
std::tie(Result.Line, Result.Column) =
LLVMSourceMgr.getLineAndColumn(Loc.Value, BufferID);
return Result;
}