diff options
| author | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2011-08-25 20:39:19 +0000 |
|---|---|---|
| committer | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2011-08-25 20:39:19 +0000 |
| commit | 7aecbc7661943f398a098b551bfe97560299a771 (patch) | |
| tree | 1f92e18ebaf20d9cd8121c8528d9b191be1739fc /clang/lib | |
| parent | 6e913571a2f4a8aeb419be5239efb228cebf6ea4 (diff) | |
| download | bcm5719-llvm-7aecbc7661943f398a098b551bfe97560299a771.tar.gz bcm5719-llvm-7aecbc7661943f398a098b551bfe97560299a771.zip | |
Make Lexer::ComputePreamble accept a LangOptions parameter, otherwise it may be
out-of-sync how a file is compiled. Patch by Matthias Kleine!
llvm-svn: 138580
Diffstat (limited to 'clang/lib')
| -rw-r--r-- | clang/lib/Frontend/ASTUnit.cpp | 4 | ||||
| -rw-r--r-- | clang/lib/Frontend/FrontendActions.cpp | 2 | ||||
| -rw-r--r-- | clang/lib/Lex/Lexer.cpp | 6 |
3 files changed, 7 insertions, 5 deletions
diff --git a/clang/lib/Frontend/ASTUnit.cpp b/clang/lib/Frontend/ASTUnit.cpp index e369f430b7a..71f9c0dada8 100644 --- a/clang/lib/Frontend/ASTUnit.cpp +++ b/clang/lib/Frontend/ASTUnit.cpp @@ -1122,7 +1122,9 @@ ASTUnit::ComputePreamble(CompilerInvocation &Invocation, CreatedBuffer = true; } - return std::make_pair(Buffer, Lexer::ComputePreamble(Buffer, MaxLines)); + return std::make_pair(Buffer, Lexer::ComputePreamble(Buffer, + Invocation.getLangOpts(), + MaxLines)); } static llvm::MemoryBuffer *CreatePaddedMainFileBuffer(llvm::MemoryBuffer *Old, diff --git a/clang/lib/Frontend/FrontendActions.cpp b/clang/lib/Frontend/FrontendActions.cpp index 4eb9cda3987..d6df141905a 100644 --- a/clang/lib/Frontend/FrontendActions.cpp +++ b/clang/lib/Frontend/FrontendActions.cpp @@ -220,7 +220,7 @@ void PrintPreambleAction::ExecuteAction() { llvm::MemoryBuffer *Buffer = CI.getFileManager().getBufferForFile(getCurrentFile()); if (Buffer) { - unsigned Preamble = Lexer::ComputePreamble(Buffer).first; + unsigned Preamble = Lexer::ComputePreamble(Buffer, CI.getLangOpts()).first; llvm::outs().write(Buffer->getBufferStart(), Preamble); delete Buffer; } diff --git a/clang/lib/Lex/Lexer.cpp b/clang/lib/Lex/Lexer.cpp index d8ebc9ffe6b..1ec50cd2c5d 100644 --- a/clang/lib/Lex/Lexer.cpp +++ b/clang/lib/Lex/Lexer.cpp @@ -505,14 +505,14 @@ namespace { } std::pair<unsigned, bool> -Lexer::ComputePreamble(const llvm::MemoryBuffer *Buffer, unsigned MaxLines) { +Lexer::ComputePreamble(const llvm::MemoryBuffer *Buffer, + const LangOptions &Features, unsigned MaxLines) { // Create a lexer starting at the beginning of the file. Note that we use a // "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); - LangOptions LangOpts; - Lexer TheLexer(StartLoc, LangOpts, Buffer->getBufferStart(), + Lexer TheLexer(StartLoc, Features, Buffer->getBufferStart(), Buffer->getBufferStart(), Buffer->getBufferEnd()); bool InPreprocessorDirective = false; |

