Change MemoryBuffer* to MemoryBuffer& parameter to Lexer::ComputePreamble

(dropping const from the reference as MemoryBuffer is immutable already,
so const is just redundant - and while I'd personally put const
everywhere, that's not the LLVM Way (see llvm::Type for another example
of an immutable type where "const" is omitted for brevity))

Changing the pointer argument to a reference parameter makes call sites
identical between callers with unique_ptrs or raw pointers, minimizing
the churn in a pending unique_ptr migrations.

llvm-svn: 215391
This commit is contained in:
David Blaikie
2014-08-11 22:08:06 +00:00
parent c64c175173
commit 3d95d858f9
4 changed files with 17 additions and 17 deletions

View File

@@ -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 {