aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Lex/Lexer.cpp
diff options
context:
space:
mode:
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>2012-10-25 01:51:45 +0000
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>2012-10-25 01:51:45 +0000
commitd53d0daab96788889eb11fe585a11120dbdc04af (patch)
tree0ba28742375a23c1a403ae7b2d824bda332e2dfb /clang/lib/Lex/Lexer.cpp
parentec8f1ef9db3417d2a091f308fe239fb779aba92b (diff)
downloadllvm-d53d0daab96788889eb11fe585a11120dbdc04af.zip
llvm-d53d0daab96788889eb11fe585a11120dbdc04af.tar.gz
llvm-d53d0daab96788889eb11fe585a11120dbdc04af.tar.bz2
Take into account that there may be a BOM at the beginning of the file,
when computing the size of the precompiled preamble. llvm-svn: 166659
Diffstat (limited to 'clang/lib/Lex/Lexer.cpp')
-rw-r--r--clang/lib/Lex/Lexer.cpp9
1 files changed, 6 insertions, 3 deletions
diff --git a/clang/lib/Lex/Lexer.cpp b/clang/lib/Lex/Lexer.cpp
index 6ac3f3f..fa911fe 100644
--- a/clang/lib/Lex/Lexer.cpp
+++ b/clang/lib/Lex/Lexer.cpp
@@ -513,10 +513,13 @@ Lexer::ComputePreamble(const llvm::MemoryBuffer *Buffer,
// "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;