]> granicus.if.org Git - clang/commitdiff
Switch another function to StringRef instead of char pointer pairs.
authorBenjamin Kramer <benny.kra@googlemail.com>
Tue, 16 Mar 2010 14:48:07 +0000 (14:48 +0000)
committerBenjamin Kramer <benny.kra@googlemail.com>
Tue, 16 Mar 2010 14:48:07 +0000 (14:48 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@98631 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Basic/SourceLocation.h
include/clang/Basic/SourceManager.h
lib/Basic/SourceLocation.cpp
lib/Frontend/HTMLDiagnostics.cpp

index d4f557b57d0b399c7f3089954ad4090708049300..34dfecd9b6a83e3863832a72231538071640be3f 100644 (file)
@@ -20,6 +20,7 @@
 namespace llvm {
   class MemoryBuffer;
   class raw_ostream;
+  class StringRef;
   template <typename T> struct DenseMapInfo;
   template <typename T> 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<const char*, const char*> 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
index 3d1fcd3dbb7c603451a41acec66efb28e583f58b..ef51a58883796b12dd07c5c3919e6b87a6b07057 100644 (file)
@@ -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;
index 578a4eb34bab50a54a8c13daab275fd15a3dbd00..126d640364d07da90a628da623f184b4005bd5cf 100644 (file)
@@ -115,9 +115,8 @@ const llvm::MemoryBuffer* FullSourceLoc::getBuffer() const {
   return SrcMgr->getBuffer(SrcMgr->getFileID(*this));
 }
 
-std::pair<const char*, const char*> 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<FileID, unsigned> FullSourceLoc::getDecomposedLoc() const {
index 4f87d00edb8fda50a731fb3c54e387b2998902d9..da99cb8b7b895e44a72cd4b55705202d92d76c0d 100644 (file)
@@ -439,10 +439,10 @@ void HTMLDiagnostics::HandlePiece(Rewriter& R, FileID BugFileID,
     {
       FullSourceLoc L = MP->getLocation().asLocation().getInstantiationLoc();
       assert(L.isFileID());
-      std::pair<const char*, const char*> 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);