wean the diagnostics machinery off the preprocessor.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@43085 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/Driver/TextDiagnosticPrinter.cpp b/Driver/TextDiagnosticPrinter.cpp
index 2a3bd0d..76809d7 100644
--- a/Driver/TextDiagnosticPrinter.cpp
+++ b/Driver/TextDiagnosticPrinter.cpp
@@ -104,13 +104,19 @@
   // the token this macro expanded to.
   Loc = SourceMgr.getLogicalLoc(Loc);
   const char *StrData = SourceMgr.getCharacterData(Loc);
+  const char *BufEnd = SourceMgr.getBufferData(Loc.getFileID()).second;
   
   // TODO: this could be special cased for common tokens like identifiers, ')',
   // etc to make this faster, if it mattered.  This could use 
   // Lexer::isObviouslySimpleCharacter for example.
   
+  // Create a langops struct and enable trigraphs.  This is sufficient for
+  // measuring tokens.
+  LangOptions LangOpts;
+  LangOpts.Trigraphs = true;
+  
   // Create a lexer starting at the beginning of this token.
-  Lexer TheLexer(Loc, *ThePreprocessor, StrData);
+  Lexer TheLexer(Loc, LangOpts, StrData, BufEnd);
   Token TheTok;
   TheLexer.LexRawToken(TheTok);
   return TheTok.getLength();