From ceafc4b63599d14f0b5b10ff92e22bf242682dce Mon Sep 17 00:00:00 2001 From: Benjamin Kramer Date: Tue, 16 Mar 2010 14:48:07 +0000 Subject: [PATCH] Switch another function to StringRef instead of char pointer pairs. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@98631 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/Basic/SourceLocation.h | 7 ++++--- include/clang/Basic/SourceManager.h | 6 +++--- lib/Basic/SourceLocation.cpp | 5 ++--- lib/Frontend/HTMLDiagnostics.cpp | 8 ++++---- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/include/clang/Basic/SourceLocation.h b/include/clang/Basic/SourceLocation.h index d4f557b57d..34dfecd9b6 100644 --- a/include/clang/Basic/SourceLocation.h +++ b/include/clang/Basic/SourceLocation.h @@ -20,6 +20,7 @@ namespace llvm { class MemoryBuffer; class raw_ostream; + class StringRef; template struct DenseMapInfo; template struct isPodLike; } @@ -209,9 +210,9 @@ public: const llvm::MemoryBuffer* getBuffer() const; - /// getBufferData - Return a pointer to the start and end of the source buffer - /// data for the specified FileID. - std::pair getBufferData() const; + /// getBufferData - Return a StringRef to the source buffer data for the + /// specified FileID. + llvm::StringRef getBufferData() const; /// getDecomposedLoc - Decompose the specified location into a raw FileID + /// Offset pair. The first element is the FileID, the second is the diff --git a/include/clang/Basic/SourceManager.h b/include/clang/Basic/SourceManager.h index 3d1fcd3dbb..ef51a58883 100644 --- a/include/clang/Basic/SourceManager.h +++ b/include/clang/Basic/SourceManager.h @@ -452,9 +452,9 @@ public: return getSLocEntry(FID).getFile().getContentCache()->Entry; } - /// getBufferData - Return a pointer to the start and end of the source buffer - /// data for the specified FileID. - /// + /// getBufferData - Return a StringRef to the source buffer data for the + /// specified FileID. + /// /// \param FID The file ID whose contents will be returned. /// \param Invalid If non-NULL, will be set true if an error occurred. llvm::StringRef getBufferData(FileID FID, bool *Invalid = 0) const; diff --git a/lib/Basic/SourceLocation.cpp b/lib/Basic/SourceLocation.cpp index 578a4eb34b..126d640364 100644 --- a/lib/Basic/SourceLocation.cpp +++ b/lib/Basic/SourceLocation.cpp @@ -115,9 +115,8 @@ const llvm::MemoryBuffer* FullSourceLoc::getBuffer() const { return SrcMgr->getBuffer(SrcMgr->getFileID(*this)); } -std::pair FullSourceLoc::getBufferData() const { - const llvm::MemoryBuffer *Buf = getBuffer(); - return std::make_pair(Buf->getBufferStart(), Buf->getBufferEnd()); +llvm::StringRef FullSourceLoc::getBufferData() const { + return getBuffer()->getBuffer(); } std::pair FullSourceLoc::getDecomposedLoc() const { diff --git a/lib/Frontend/HTMLDiagnostics.cpp b/lib/Frontend/HTMLDiagnostics.cpp index 4f87d00edb..da99cb8b7b 100644 --- a/lib/Frontend/HTMLDiagnostics.cpp +++ b/lib/Frontend/HTMLDiagnostics.cpp @@ -439,10 +439,10 @@ void HTMLDiagnostics::HandlePiece(Rewriter& R, FileID BugFileID, { FullSourceLoc L = MP->getLocation().asLocation().getInstantiationLoc(); assert(L.isFileID()); - std::pair BufferInfo = L.getBufferData(); - const char* MacroName = L.getDecomposedLoc().second + BufferInfo.first; - Lexer rawLexer(L, PP.getLangOptions(), BufferInfo.first, - MacroName, BufferInfo.second); + llvm::StringRef BufferInfo = L.getBufferData(); + const char* MacroName = L.getDecomposedLoc().second + BufferInfo.data(); + Lexer rawLexer(L, PP.getLangOptions(), BufferInfo.begin(), + MacroName, BufferInfo.end()); Token TheTok; rawLexer.LexFromRawLexer(TheTok); -- 2.40.0