Change Lexer::MeasureTokenLength to take a LangOptions reference.
This allows it to accurately measure tokens, so that we get:

t.cpp:8:13: error: unknown type name 'X'
static foo::X  P;
       ~~~~~^

instead of the woefully inferior:

t.cpp:8:13: error: unknown type name 'X'
static foo::X  P;
       ~~~~ ^

Most of this is just plumbing to push the reference around.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69099 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/tools/clang-cc/RewriteObjC.cpp b/tools/clang-cc/RewriteObjC.cpp
index 44c0eb3..41f532b 100644
--- a/tools/clang-cc/RewriteObjC.cpp
+++ b/tools/clang-cc/RewriteObjC.cpp
@@ -455,7 +455,7 @@
   MainFileStart = MainBuf->getBufferStart();
   MainFileEnd = MainBuf->getBufferEnd();
      
-  Rewrite.setSourceMgr(Context->getSourceManager());
+  Rewrite.setSourceMgr(Context->getSourceManager(), Context->getLangOptions());
   
   // declaring objc_selector outside the parameter list removes a silly
   // scope related warning...
@@ -2673,7 +2673,7 @@
   // have no ivars (thus not synthesized) then no need to synthesize this class.
   if ((CDecl->isForwardDecl() || NumIvars == 0) &&
       (!RCDecl || !ObjCSynthesizedStructs.count(RCDecl))) {
-    endBuf += Lexer::MeasureTokenLength(LocEnd, *SM);
+    endBuf += Lexer::MeasureTokenLength(LocEnd, *SM, LangOpts);
     ReplaceText(LocStart, endBuf-startBuf, Result.c_str(), Result.size());
     return;
   }
@@ -2708,7 +2708,7 @@
       SourceLocation L = RCDecl ? CDecl->getSuperClassLoc() : 
                                   CDecl->getClassLoc();
       const char *endHeader = SM->getCharacterData(L);
-      endHeader += Lexer::MeasureTokenLength(L, *SM);
+      endHeader += Lexer::MeasureTokenLength(L, *SM, LangOpts);
 
       if (CDecl->protocol_begin() != CDecl->protocol_end()) {
         // advance to the end of the referenced protocols.
@@ -2770,7 +2770,7 @@
     // Don't forget to add a ';'!!
     InsertText(LocEnd.getFileLocWithOffset(1), ";", 1);
   } else { // we don't have any instance variables - insert super struct.
-    endBuf += Lexer::MeasureTokenLength(LocEnd, *SM);
+    endBuf += Lexer::MeasureTokenLength(LocEnd, *SM, LangOpts);
     Result += " {\n    struct ";
     Result += RCDecl->getNameAsString();
     Result += "_IMPL ";