diff options
author | David Blaikie <dblaikie@gmail.com> | 2014-08-11 22:08:06 +0000 |
---|---|---|
committer | David Blaikie <dblaikie@gmail.com> | 2014-08-11 22:08:06 +0000 |
commit | 3d95d858f9a46d792d83f31466880f07cefc1ba8 (patch) | |
tree | b7775b2062472042af1075b59045ba02aa3b3b28 /clang/lib/Lex/Lexer.cpp | |
parent | c64c1751738ecd3c3fb388aaaaced56b010a6607 (diff) | |
download | llvm-3d95d858f9a46d792d83f31466880f07cefc1ba8.zip llvm-3d95d858f9a46d792d83f31466880f07cefc1ba8.tar.gz llvm-3d95d858f9a46d792d83f31466880f07cefc1ba8.tar.bz2 |
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
Diffstat (limited to 'clang/lib/Lex/Lexer.cpp')
-rw-r--r-- | clang/lib/Lex/Lexer.cpp | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/clang/lib/Lex/Lexer.cpp b/clang/lib/Lex/Lexer.cpp index 6f6b50b..efee609 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 { |