From: Ted Kremenek Date: Wed, 28 Jan 2009 20:46:26 +0000 (+0000) Subject: Add method FullSourceLoc::getBufferData(). X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3632a35e811096da86d957c3e6ba0e73d75782f5;p=clang Add method FullSourceLoc::getBufferData(). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63229 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/Basic/SourceLocation.h b/include/clang/Basic/SourceLocation.h index 31fbc0218b..4a6ae1f29d 100644 --- a/include/clang/Basic/SourceLocation.h +++ b/include/clang/Basic/SourceLocation.h @@ -16,6 +16,7 @@ #include #include "llvm/Bitcode/SerializationFwd.h" +#include namespace llvm { class MemoryBuffer; @@ -178,7 +179,7 @@ public: 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 @@ 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; + bool isInSystemHeader() const; /// Prints information about this FullSourceLoc to stderr. Useful for diff --git a/lib/Basic/SourceLocation.cpp b/lib/Basic/SourceLocation.cpp index 5d484721bd..43fa3a13a6 100644 --- a/lib/Basic/SourceLocation.cpp +++ b/lib/Basic/SourceLocation.cpp @@ -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 @@ 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()); +}