split buffer management and diagnostic printing out of the tblgen
lexer into its own TGSourceMgr class.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@66873 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/utils/TableGen/TGLexer.h b/utils/TableGen/TGLexer.h
index 0e67f68..59e9fa0 100644
--- a/utils/TableGen/TGLexer.h
+++ b/utils/TableGen/TGLexer.h
@@ -22,6 +22,7 @@
 
 namespace llvm {
 class MemoryBuffer;
+class TGSourceMgr;
   
 namespace tgtok {
   enum TokKind {
@@ -55,33 +56,27 @@
 
 /// TGLexer - TableGen Lexer class.
 class TGLexer {
+  TGSourceMgr &SrcMgr;
+  
   const char *CurPtr;
-  unsigned CurLineNo;
-  MemoryBuffer *CurBuf;
+  const MemoryBuffer *CurBuf;
 
   // Information about the current token.
   const char *TokStart;
   tgtok::TokKind CurCode;
   std::string CurStrVal;  // This is valid for ID, STRVAL, VARNAME, CODEFRAGMENT
   int64_t CurIntVal;      // This is valid for INTVAL.
-  
-  /// IncludeRec / IncludeStack - This captures the current set of include
-  /// directives we are nested within.
-  struct IncludeRec {
-    MemoryBuffer *Buffer;
-    const char *CurPtr;
-    unsigned LineNo;
-    IncludeRec(MemoryBuffer *buffer, const char *curPtr, unsigned lineNo)
-      : Buffer(buffer), CurPtr(curPtr), LineNo(lineNo) {}
-  };
-  std::vector<IncludeRec> IncludeStack;
+
+  /// CurBuffer - This is the current buffer index we're lexing from as managed
+  /// by the SourceMgr object.
+  int CurBuffer;
   
   // IncludeDirectories - This is the list of directories we should search for
   // include files in.
   std::vector<std::string> IncludeDirectories;
 public:
-  TGLexer(MemoryBuffer *StartBuf);
-  ~TGLexer();
+  TGLexer(TGSourceMgr &SrcMgr);
+  ~TGLexer() {}
   
   void setIncludeDirs(const std::vector<std::string> &Dirs) {
     IncludeDirectories = Dirs;
@@ -109,8 +104,6 @@
 
   void PrintError(LocTy Loc, const std::string &Msg) const;
   
-  void PrintIncludeStack(std::ostream &OS) const;
-  
 private:
   /// LexToken - Read the next token and return its code.
   tgtok::TokKind LexToken();