[cfe-commits] r63229 - in /cfe/trunk: include/clang/Basic/SourceLocation.h lib/Basic/SourceLocation.cpp

Ted Kremenek kremenek at apple.com
Wed Jan 28 12:46:26 PST 2009


Author: kremenek
Date: Wed Jan 28 14:46:26 2009
New Revision: 63229

URL: http://llvm.org/viewvc/llvm-project?rev=63229&view=rev
Log:
Add method FullSourceLoc::getBufferData().

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

Modified: cfe/trunk/include/clang/Basic/SourceLocation.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/SourceLocation.h?rev=63229&r1=63228&r2=63229&view=diff

==============================================================================
--- cfe/trunk/include/clang/Basic/SourceLocation.h (original)
+++ cfe/trunk/include/clang/Basic/SourceLocation.h Wed Jan 28 14:46:26 2009
@@ -16,6 +16,7 @@
 
 #include <cassert>
 #include "llvm/Bitcode/SerializationFwd.h"
+#include <utility>
 
 namespace llvm {
   class MemoryBuffer;
@@ -178,7 +179,7 @@
 class FullSourceLoc : public SourceLocation {
   SourceManager* SrcMgr;
 public:
-  // Creates a FullSourceLoc where isValid() returns false.
+  /// Creates a FullSourceLoc where isValid() returns false.
   explicit FullSourceLoc() : SrcMgr((SourceManager*) 0) {}
 
   explicit FullSourceLoc(SourceLocation Loc, SourceManager &SM) 
@@ -212,6 +213,10 @@
   
   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;
+  
   bool isInSystemHeader() const;
   
   /// Prints information about this FullSourceLoc to stderr. Useful for

Modified: cfe/trunk/lib/Basic/SourceLocation.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/SourceLocation.cpp?rev=63229&r1=63228&r2=63229&view=diff

==============================================================================
--- cfe/trunk/lib/Basic/SourceLocation.cpp (original)
+++ cfe/trunk/lib/Basic/SourceLocation.cpp Wed Jan 28 14:46:26 2009
@@ -16,6 +16,8 @@
 #include "clang/Basic/SourceManager.h"
 #include "llvm/Bitcode/Serialize.h"
 #include "llvm/Bitcode/Deserialize.h"
+#include "llvm/Support/MemoryBuffer.h"
+
 using namespace clang;
 
 void SourceLocation::Emit(llvm::Serializer& S) const {
@@ -122,3 +124,7 @@
   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());
+}





More information about the cfe-commits mailing list