Author: alexfh Date: Tue Jun 4 11:58:03 2013 New Revision: 183236 URL: http://llvm.org/viewvc/llvm-project?rev=183236&view=rev Log: 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 Modified: cfe/trunk/include/clang/Lex/Lexer.h cfe/trunk/lib/Rewrite/Core/HTMLRewrite.cpp Modified: cfe/trunk/include/clang/Lex/Lexer.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/Lexer.h?rev=183236&r1=183235&r2=183236&view=diff ============================================================================== --- cfe/trunk/include/clang/Lex/Lexer.h (original) +++ cfe/trunk/include/clang/Lex/Lexer.h Tue Jun 4 11:58:03 2013 @@ -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. Modified: cfe/trunk/lib/Rewrite/Core/HTMLRewrite.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Rewrite/Core/HTMLRewrite.cpp?rev=183236&r1=183235&r2=183236&view=diff ============================================================================== --- cfe/trunk/lib/Rewrite/Core/HTMLRewrite.cpp (original) +++ cfe/trunk/lib/Rewrite/Core/HTMLRewrite.cpp Tue Jun 4 11:58:03 2013 @@ -361,7 +361,7 @@ void html::SyntaxHighlight(Rewriter &R, 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. _______________________________________________ cfe-commits mailing list [email protected] http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
