Added Lexer::getBufferEnd().

Summary:
There's Lexer::getBufferStart(), and we need getBufferEnd() to access
the whole input buffer in clang::format::reformat. We don't want to
rely on the fact that the Lexer::BufferEnd always points to '\0', as there can
be embedded '\0's as well.

Reviewers: jordan_rose

Reviewed By: jordan_rose

CC: cfe-commits

Differential Revision: http://llvm-reviews.chandlerc.com/D916

llvm-svn: 183236
This commit is contained in:
Alexander Kornienko 2013-06-04 16:58:03 +00:00
parent f0dc11ad7f
commit 33a35dff83
2 changed files with 5 additions and 2 deletions

View File

@ -202,7 +202,10 @@ public:
/// lexer has nothing to reset to.
void resetExtendedTokenMode();
const char *getBufferStart() const { return BufferStart; }
/// Gets source code buffer.
StringRef getBuffer() const {
return StringRef(BufferStart, BufferEnd - BufferStart);
}
/// ReadToEndOfLine - Read the rest of the current preprocessor line as an
/// uninterpreted string. This switches the lexer out of directive mode.

View File

@ -361,7 +361,7 @@ void html::SyntaxHighlight(Rewriter &R, FileID FID, const Preprocessor &PP) {
const SourceManager &SM = PP.getSourceManager();
const llvm::MemoryBuffer *FromFile = SM.getBuffer(FID);
Lexer L(FID, FromFile, SM, PP.getLangOpts());
const char *BufferStart = L.getBufferStart();
const char *BufferStart = L.getBuffer().data();
// Inform the preprocessor that we want to retain comments as tokens, so we
// can highlight them.