diff options
author | Chris Lattner <sabre@nondot.org> | 2009-02-04 00:55:58 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2009-02-04 00:55:58 +0000 |
commit | 7da5aea7669e6db3e593162b8a123aef06a04d07 (patch) | |
tree | 4af3a673a35337a49ec9d99787d73fd82588c227 /lib/Driver | |
parent | be395f6b29762c37938637ffef5f59514e04751a (diff) |
make SM::getColumnNumber take a predecomposed FileID/offset, which
makes it clear to clients that they have to pick an instantiation
or spelling location before calling it and allows optimization based
on that.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63698 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Driver')
-rw-r--r-- | lib/Driver/HTMLDiagnostics.cpp | 19 | ||||
-rw-r--r-- | lib/Driver/TextDiagnosticPrinter.cpp | 4 |
2 files changed, 11 insertions, 12 deletions
diff --git a/lib/Driver/HTMLDiagnostics.cpp b/lib/Driver/HTMLDiagnostics.cpp index 6b60588ca5..1e1190527f 100644 --- a/lib/Driver/HTMLDiagnostics.cpp +++ b/lib/Driver/HTMLDiagnostics.cpp @@ -336,20 +336,19 @@ void HTMLDiagnostics::HandlePiece(Rewriter& R, FileID BugFileID, return; SourceManager &SM = R.getSourceMgr(); - FullSourceLoc LPos = Pos.getInstantiationLoc(); - FileID FID = SM.getFileID(LPos); - assert(&LPos.getManager() == &SM && "SourceManagers are different!"); + assert(&Pos.getManager() == &SM && "SourceManagers are different!"); + std::pair<FileID, unsigned> LPosInfo = SM.getDecomposedInstantiationLoc(Pos); - if (SM.getFileID(LPos) != BugFileID) + if (LPosInfo.first != BugFileID) return; - const llvm::MemoryBuffer *Buf = SM.getBuffer(FID); + const llvm::MemoryBuffer *Buf = SM.getBuffer(LPosInfo.first); const char* FileStart = Buf->getBufferStart(); // Compute the column number. Rewind from the current position to the start // of the line. - unsigned ColNo = LPos.getColumnNumber(); - const char *TokInstantiationPtr = LPos.getCharacterData(); + unsigned ColNo = SM.getColumnNumber(LPosInfo.first, LPosInfo.second); + const char *TokInstantiationPtr =Pos.getInstantiationLoc().getCharacterData(); const char *LineStart = TokInstantiationPtr-ColNo; // Only compute LineEnd if we display below a line. @@ -445,7 +444,7 @@ void HTMLDiagnostics::HandlePiece(Rewriter& R, FileID BugFileID, } SourceLocation Loc = - SM.getLocForStartOfFile(FID).getFileLocWithOffset(DisplayPos); + SM.getLocForStartOfFile(LPosInfo.first).getFileLocWithOffset(DisplayPos); R.InsertStrBefore(Loc, os.str()); } @@ -453,7 +452,7 @@ void HTMLDiagnostics::HandlePiece(Rewriter& R, FileID BugFileID, for (const SourceRange *I = P.ranges_begin(), *E = P.ranges_end(); I != E; ++I) - HighlightRange(R, FID, *I); + HighlightRange(R, LPosInfo.first, *I); } void HTMLDiagnostics::HighlightRange(Rewriter& R, FileID BugFileID, @@ -475,7 +474,7 @@ void HTMLDiagnostics::HighlightRange(Rewriter& R, FileID BugFileID, return; // Compute the column number of the end. - unsigned EndColNo = SM.getColumnNumber(InstantiationEnd); + unsigned EndColNo = SM.getInstantiationColumnNumber(InstantiationEnd); unsigned OldEndColNo = EndColNo; if (EndColNo) { diff --git a/lib/Driver/TextDiagnosticPrinter.cpp b/lib/Driver/TextDiagnosticPrinter.cpp index 27353b8344..cf3733f2e9 100644 --- a/lib/Driver/TextDiagnosticPrinter.cpp +++ b/lib/Driver/TextDiagnosticPrinter.cpp @@ -56,7 +56,7 @@ void TextDiagnosticPrinter::HighlightRange(const SourceRange &R, // Compute the column number of the start. unsigned StartColNo = 0; if (StartLineNo == LineNo) { - StartColNo = SM.getColumnNumber(Begin); + StartColNo = SM.getInstantiationColumnNumber(Begin); if (StartColNo) --StartColNo; // Zero base the col #. } @@ -68,7 +68,7 @@ void TextDiagnosticPrinter::HighlightRange(const SourceRange &R, // Compute the column number of the end. unsigned EndColNo = CaretLine.size(); if (EndLineNo == LineNo) { - EndColNo = SM.getColumnNumber(End); + EndColNo = SM.getInstantiationColumnNumber(End); if (EndColNo) { --EndColNo; // Zero base the col #. |