diff options
author | Chris Lattner <sabre@nondot.org> | 2009-03-13 16:01:53 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2009-03-13 16:01:53 +0000 |
commit | 1c8ae59dfdc85d917db0333ae0b93e2be4ca6c36 (patch) | |
tree | 6f5e05ef52d3c8eac1f42518dc5d7db4be9d8949 /utils/TableGen/TGSourceMgr.cpp | |
parent | d9c9bf77d82a00c2fe34db2da00244523f4ac288 (diff) |
make "locations" a class instead of a typedef.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@66895 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'utils/TableGen/TGSourceMgr.cpp')
-rw-r--r-- | utils/TableGen/TGSourceMgr.cpp | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/utils/TableGen/TGSourceMgr.cpp b/utils/TableGen/TGSourceMgr.cpp index 1e0ab7e368..9c39230def 100644 --- a/utils/TableGen/TGSourceMgr.cpp +++ b/utils/TableGen/TGSourceMgr.cpp @@ -25,17 +25,17 @@ TGSourceMgr::~TGSourceMgr() { /// FindBufferContainingLoc - Return the ID of the buffer containing the /// specified location, returning -1 if not found. -int TGSourceMgr::FindBufferContainingLoc(TGLocTy Loc) const { +int TGSourceMgr::FindBufferContainingLoc(TGLoc Loc) const { for (unsigned i = 0, e = Buffers.size(); i != e; ++i) - if (Loc >= Buffers[i].Buffer->getBufferStart() && - Loc < Buffers[i].Buffer->getBufferEnd()) + if (Loc.getPointer() >= Buffers[i].Buffer->getBufferStart() && + Loc.getPointer() < Buffers[i].Buffer->getBufferEnd()) return i; return -1; } /// FindLineNumber - Find the line number for the specified location in the /// specified file. This is not a fast method. -unsigned TGSourceMgr::FindLineNumber(TGLocTy Loc, int BufferID) const { +unsigned TGSourceMgr::FindLineNumber(TGLoc Loc, int BufferID) const { if (BufferID == -1) BufferID = FindBufferContainingLoc(Loc); assert(BufferID != -1 && "Invalid Location!"); @@ -47,13 +47,13 @@ unsigned TGSourceMgr::FindLineNumber(TGLocTy Loc, int BufferID) const { const char *Ptr = Buff->getBufferStart(); - for (; Ptr != Loc; ++Ptr) + for (; TGLoc::getFromPointer(Ptr) != Loc; ++Ptr) if (*Ptr == '\n') ++LineNo; return LineNo; } -void TGSourceMgr::PrintIncludeStack(TGLocTy IncludeLoc) const { - if (IncludeLoc == TGLocTy()) return; // Top of stack. +void TGSourceMgr::PrintIncludeStack(TGLoc IncludeLoc) const { + if (IncludeLoc == TGLoc()) return; // Top of stack. int CurBuf = FindBufferContainingLoc(IncludeLoc); assert(CurBuf != -1 && "Invalid or unspecified location!"); @@ -66,7 +66,7 @@ void TGSourceMgr::PrintIncludeStack(TGLocTy IncludeLoc) const { } -void TGSourceMgr::PrintError(TGLocTy ErrorLoc, const std::string &Msg) const { +void TGSourceMgr::PrintError(TGLoc ErrorLoc, const std::string &Msg) const { raw_ostream &OS = errs(); // First thing to do: find the current buffer containing the specified @@ -83,22 +83,21 @@ void TGSourceMgr::PrintError(TGLocTy ErrorLoc, const std::string &Msg) const { << FindLineNumber(ErrorLoc, CurBuf) << ": "; OS << Msg << "\n"; - assert(ErrorLoc && "Location not specified!"); // Scan backward to find the start of the line. - const char *LineStart = ErrorLoc; + const char *LineStart = ErrorLoc.getPointer(); while (LineStart != CurMB->getBufferStart() && LineStart[-1] != '\n' && LineStart[-1] != '\r') --LineStart; // Get the end of the line. - const char *LineEnd = ErrorLoc; + const char *LineEnd = ErrorLoc.getPointer(); while (LineEnd != CurMB->getBufferEnd() && LineEnd[0] != '\n' && LineEnd[0] != '\r') ++LineEnd; // Print out the line. OS << std::string(LineStart, LineEnd) << "\n"; // Print out spaces before the carat. - for (const char *Pos = LineStart; Pos != ErrorLoc; ++Pos) + for (const char *Pos = LineStart; Pos != ErrorLoc.getPointer(); ++Pos) OS << (*Pos == '\t' ? '\t' : ' '); OS << "^\n"; } |