[cfe-commits] r98631 - in /cfe/trunk: include/clang/Basic/SourceLocation.h include/clang/Basic/SourceManager.h lib/Basic/SourceLocation.cpp lib/Frontend/HTMLDiagnostics.cpp

Benjamin Kramer benny.kra at googlemail.com
Tue Mar 16 07:48:08 PDT 2010


Author: d0k
Date: Tue Mar 16 09:48:07 2010
New Revision: 98631

URL: http://llvm.org/viewvc/llvm-project?rev=98631&view=rev
Log:
Switch another function to StringRef instead of char pointer pairs.

Modified:
    cfe/trunk/include/clang/Basic/SourceLocation.h
    cfe/trunk/include/clang/Basic/SourceManager.h
    cfe/trunk/lib/Basic/SourceLocation.cpp
    cfe/trunk/lib/Frontend/HTMLDiagnostics.cpp

Modified: cfe/trunk/include/clang/Basic/SourceLocation.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/SourceLocation.h?rev=98631&r1=98630&r2=98631&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/SourceLocation.h (original)
+++ cfe/trunk/include/clang/Basic/SourceLocation.h Tue Mar 16 09:48:07 2010
@@ -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 @@
 
   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

Modified: cfe/trunk/include/clang/Basic/SourceManager.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/SourceManager.h?rev=98631&r1=98630&r2=98631&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/SourceManager.h (original)
+++ cfe/trunk/include/clang/Basic/SourceManager.h Tue Mar 16 09:48:07 2010
@@ -452,9 +452,9 @@
     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;

Modified: cfe/trunk/lib/Basic/SourceLocation.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/SourceLocation.cpp?rev=98631&r1=98630&r2=98631&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/SourceLocation.cpp (original)
+++ cfe/trunk/lib/Basic/SourceLocation.cpp Tue Mar 16 09:48:07 2010
@@ -115,9 +115,8 @@
   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 {

Modified: cfe/trunk/lib/Frontend/HTMLDiagnostics.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/HTMLDiagnostics.cpp?rev=98631&r1=98630&r2=98631&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/HTMLDiagnostics.cpp (original)
+++ cfe/trunk/lib/Frontend/HTMLDiagnostics.cpp Tue Mar 16 09:48:07 2010
@@ -439,10 +439,10 @@
     {
       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);





More information about the cfe-commits mailing list