summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/Frontend/ASTUnit.cpp8
-rw-r--r--clang/lib/Frontend/FrontendActions.cpp2
-rw-r--r--clang/lib/Lex/Lexer.cpp18
3 files changed, 14 insertions, 14 deletions
diff --git a/clang/lib/Frontend/ASTUnit.cpp b/clang/lib/Frontend/ASTUnit.cpp
index 0b740e7a116..f6c2a405159 100644
--- a/clang/lib/Frontend/ASTUnit.cpp
+++ b/clang/lib/Frontend/ASTUnit.cpp
@@ -1252,10 +1252,10 @@ ASTUnit::ComputePreamble(CompilerInvocation &Invocation,
CreatedBuffer = true;
}
-
- return std::make_pair(Buffer, Lexer::ComputePreamble(Buffer,
- *Invocation.getLangOpts(),
- MaxLines));
+
+ return std::make_pair(
+ Buffer,
+ Lexer::ComputePreamble(*Buffer, *Invocation.getLangOpts(), MaxLines));
}
ASTUnit::PreambleFileHash
diff --git a/clang/lib/Frontend/FrontendActions.cpp b/clang/lib/Frontend/FrontendActions.cpp
index 903abe2d61f..e5830d6ae68 100644
--- a/clang/lib/Frontend/FrontendActions.cpp
+++ b/clang/lib/Frontend/FrontendActions.cpp
@@ -685,7 +685,7 @@ void PrintPreambleAction::ExecuteAction() {
llvm::MemoryBuffer *Buffer
= CI.getFileManager().getBufferForFile(getCurrentFile());
if (Buffer) {
- unsigned Preamble = Lexer::ComputePreamble(Buffer, CI.getLangOpts()).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 6f6b50b246d..efee609fc10 100644
--- a/clang/lib/Lex/Lexer.cpp
+++ b/clang/lib/Lex/Lexer.cpp
@@ -540,16 +540,16 @@ namespace {
};
}
-std::pair<unsigned, bool>
-Lexer::ComputePreamble(const llvm::MemoryBuffer *Buffer,
- const LangOptions &LangOpts, unsigned MaxLines) {
+std::pair<unsigned, bool> Lexer::ComputePreamble(llvm::MemoryBuffer &Buffer,
+ const LangOptions &LangOpts,
+ 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 FileLoc = SourceLocation::getFromRawEncoding(StartOffset);
- Lexer TheLexer(FileLoc, LangOpts, Buffer->getBufferStart(),
- Buffer->getBufferStart(), Buffer->getBufferEnd());
+ Lexer TheLexer(FileLoc, LangOpts, Buffer.getBufferStart(),
+ Buffer.getBufferStart(), Buffer.getBufferEnd());
TheLexer.SetCommentRetentionState(true);
// StartLoc will differ from FileLoc if there is a BOM that was skipped.
@@ -563,9 +563,9 @@ Lexer::ComputePreamble(const llvm::MemoryBuffer *Buffer,
unsigned MaxLineOffset = 0;
if (MaxLines) {
- const char *CurPtr = Buffer->getBufferStart();
+ const char *CurPtr = Buffer.getBufferStart();
unsigned CurLine = 0;
- while (CurPtr != Buffer->getBufferEnd()) {
+ while (CurPtr != Buffer.getBufferEnd()) {
char ch = *CurPtr++;
if (ch == '\n') {
++CurLine;
@@ -573,8 +573,8 @@ Lexer::ComputePreamble(const llvm::MemoryBuffer *Buffer,
break;
}
}
- if (CurPtr != Buffer->getBufferEnd())
- MaxLineOffset = CurPtr - Buffer->getBufferStart();
+ if (CurPtr != Buffer.getBufferEnd())
+ MaxLineOffset = CurPtr - Buffer.getBufferStart();
}
do {
OpenPOWER on IntegriCloud