summaryrefslogtreecommitdiffstats
path: root/clang
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2009-01-28 20:46:26 +0000
committerTed Kremenek <kremenek@apple.com>2009-01-28 20:46:26 +0000
commitbf16554640037086bec7d6b7a179d8872a4acee9 (patch)
tree80110e69e031bd38f6441c2cfccde687a0d75cb0 /clang
parent3587d0b76230c87182ba99e52298fa247836bad6 (diff)
downloadbcm5719-llvm-bf16554640037086bec7d6b7a179d8872a4acee9.tar.gz
bcm5719-llvm-bf16554640037086bec7d6b7a179d8872a4acee9.zip
Add method FullSourceLoc::getBufferData().
llvm-svn: 63229
Diffstat (limited to 'clang')
-rw-r--r--clang/include/clang/Basic/SourceLocation.h7
-rw-r--r--clang/lib/Basic/SourceLocation.cpp6
2 files changed, 12 insertions, 1 deletions
diff --git a/clang/include/clang/Basic/SourceLocation.h b/clang/include/clang/Basic/SourceLocation.h
index 31fbc0218bb..4a6ae1f29d0 100644
--- a/clang/include/clang/Basic/SourceLocation.h
+++ b/clang/include/clang/Basic/SourceLocation.h
@@ -16,6 +16,7 @@
#include <cassert>
#include "llvm/Bitcode/SerializationFwd.h"
+#include <utility>
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<const char*, const char*> getBufferData() const;
+
bool isInSystemHeader() const;
/// Prints information about this FullSourceLoc to stderr. Useful for
diff --git a/clang/lib/Basic/SourceLocation.cpp b/clang/lib/Basic/SourceLocation.cpp
index 5d484721bd4..43fa3a13a6f 100644
--- a/clang/lib/Basic/SourceLocation.cpp
+++ b/clang/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<const char*, const char*> FullSourceLoc::getBufferData() const {
+ const llvm::MemoryBuffer *Buf = getBuffer();
+ return std::make_pair(Buf->getBufferStart(), Buf->getBufferEnd());
+}
OpenPOWER on IntegriCloud