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
diff --git a/utils/TableGen/TGSourceMgr.cpp b/utils/TableGen/TGSourceMgr.cpp
index 1e0ab7e..9c39230 100644
--- a/utils/TableGen/TGSourceMgr.cpp
+++ b/utils/TableGen/TGSourceMgr.cpp
@@ -25,17 +25,17 @@
 
 /// 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 @@
   
   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::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 @@
      << 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";
 }