/// of the file begins along with a boolean value indicating whether
/// the preamble ends at the beginning of a new line.
static std::pair<unsigned, bool>
- ComputePreamble(const llvm::MemoryBuffer *Buffer, unsigned MaxLines = 0);
+ ComputePreamble(const llvm::MemoryBuffer *Buffer, const LangOptions &Features,
+ unsigned MaxLines = 0);
//===--------------------------------------------------------------------===//
// Internal implementation interfaces.
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,
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;
}
}
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;
// Preamble detection test: see below for comments and test commands.
-//
+//* A BCPL comment that includes '/*'
#include <blah>
#ifndef FOO
#else
// RUN: FileCheck < %t %s
// CHECK: // Preamble detection test: see below for comments and test commands.
-// CHECK-NEXT: //
+// CHECK-NEXT: //* A BCPL comment that includes '/*'
// CHECK-NEXT: #include <blah>
// CHECK-NEXT: #ifndef FOO
// CHECK-NEXT: #else