[cfe-commits] r166659 - in /cfe/trunk: lib/Lex/Lexer.cpp test/Index/preamble-reparse-with-BOM.m

Argyrios Kyrtzidis akyrtzi at gmail.com
Wed Oct 24 18:51:45 PDT 2012


Author: akirtzidis
Date: Wed Oct 24 20:51:45 2012
New Revision: 166659

URL: http://llvm.org/viewvc/llvm-project?rev=166659&view=rev
Log:
Take into account that there may be a BOM at the beginning of the file,
when computing the size of the precompiled preamble.

Added:
    cfe/trunk/test/Index/preamble-reparse-with-BOM.m
Modified:
    cfe/trunk/lib/Lex/Lexer.cpp

Modified: cfe/trunk/lib/Lex/Lexer.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/Lexer.cpp?rev=166659&r1=166658&r2=166659&view=diff
==============================================================================
--- cfe/trunk/lib/Lex/Lexer.cpp (original)
+++ cfe/trunk/lib/Lex/Lexer.cpp Wed Oct 24 20:51:45 2012
@@ -513,10 +513,13 @@
   // "fake" file source location at offset 1 so that the lexer will track our
   // position within the file.
   const unsigned StartOffset = 1;
-  SourceLocation StartLoc = SourceLocation::getFromRawEncoding(StartOffset);
-  Lexer TheLexer(StartLoc, LangOpts, Buffer->getBufferStart(),
+  SourceLocation FileLoc = SourceLocation::getFromRawEncoding(StartOffset);
+  Lexer TheLexer(FileLoc, LangOpts, Buffer->getBufferStart(),
                  Buffer->getBufferStart(), Buffer->getBufferEnd());
-  
+
+  // StartLoc will differ from FileLoc if there is a BOM that was skipped.
+  SourceLocation StartLoc = TheLexer.getSourceLocation();
+
   bool InPreprocessorDirective = false;
   Token TheTok;
   Token IfStartTok;

Added: cfe/trunk/test/Index/preamble-reparse-with-BOM.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/preamble-reparse-with-BOM.m?rev=166659&view=auto
==============================================================================
--- cfe/trunk/test/Index/preamble-reparse-with-BOM.m (added)
+++ cfe/trunk/test/Index/preamble-reparse-with-BOM.m Wed Oct 24 20:51:45 2012
@@ -0,0 +1,6 @@
+
+ at interface I2
+ at end
+
+// RUN: env CINDEXTEST_EDITING=1 CINDEXTEST_FAILONERROR=1 \
+// RUN:   c-index-test -test-load-source-reparse 1 local %s





More information about the cfe-commits mailing list