diff options
author | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2020-10-12 18:00:55 -0400 |
---|---|---|
committer | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2020-10-13 16:43:49 -0400 |
commit | f2b7d9f7faa2788e362a91761a1624fb6b020851 (patch) | |
tree | 3bd80f40344d9c51e9353e2ba687643ce4f733e1 /llvm/lib/Support/LineIterator.cpp | |
parent | f0875971249b59b5a4c07cedc9633f0359cf6b73 (diff) | |
download | llvm-f2b7d9f7faa2788e362a91761a1624fb6b020851.zip llvm-f2b7d9f7faa2788e362a91761a1624fb6b020851.tar.gz llvm-f2b7d9f7faa2788e362a91761a1624fb6b020851.tar.bz2 |
Support: Allow use of MemoryBufferRef with line_iterator
Split out from https://reviews.llvm.org/D66782, use `Optional<MemoryBufferRef>`
in `line_iterator` so you don't need access to a `MemoryBuffer*`. Follow up
patches in `clang/` will leverage this.
Differential Revision: https://reviews.llvm.org/D89280
Diffstat (limited to 'llvm/lib/Support/LineIterator.cpp')
-rw-r--r-- | llvm/lib/Support/LineIterator.cpp | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/llvm/lib/Support/LineIterator.cpp b/llvm/lib/Support/LineIterator.cpp index 164436a..7bdf127 100644 --- a/llvm/lib/Support/LineIterator.cpp +++ b/llvm/lib/Support/LineIterator.cpp @@ -33,7 +33,11 @@ static bool skipIfAtLineEnd(const char *&P) { line_iterator::line_iterator(const MemoryBuffer &Buffer, bool SkipBlanks, char CommentMarker) - : Buffer(Buffer.getBufferSize() ? &Buffer : nullptr), + : line_iterator(Buffer.getMemBufferRef(), SkipBlanks, CommentMarker) {} + +line_iterator::line_iterator(const MemoryBufferRef &Buffer, bool SkipBlanks, + char CommentMarker) + : Buffer(Buffer.getBufferSize() ? Optional<MemoryBufferRef>(Buffer) : None), CommentMarker(CommentMarker), SkipBlanks(SkipBlanks), LineNumber(1), CurrentLine(Buffer.getBufferSize() ? Buffer.getBufferStart() : nullptr, 0) { @@ -78,7 +82,7 @@ void line_iterator::advance() { if (*Pos == '\0') { // We've hit the end of the buffer, reset ourselves to the end state. - Buffer = nullptr; + Buffer = None; CurrentLine = StringRef(); return; } |