aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Support
diff options
context:
space:
mode:
authorDerek Schuff <dschuff@google.com>2012-02-29 01:09:06 +0000
committerDerek Schuff <dschuff@google.com>2012-02-29 01:09:06 +0000
commitadef06a71458ded0716935a61b3d43d164d4df12 (patch)
treed56aeec7dde89874b58254175d112ba1e5fddcb5 /lib/Support
parent95fe7b9b7251d33ad4128603087edac70cec7c72 (diff)
downloadexternal_llvm-adef06a71458ded0716935a61b3d43d164d4df12.zip
external_llvm-adef06a71458ded0716935a61b3d43d164d4df12.tar.gz
external_llvm-adef06a71458ded0716935a61b3d43d164d4df12.tar.bz2
Make MemoryObject accessor members const again
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@151687 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Support')
-rw-r--r--lib/Support/MemoryObject.cpp2
-rw-r--r--lib/Support/StreamableMemoryObject.cpp35
2 files changed, 20 insertions, 17 deletions
diff --git a/lib/Support/MemoryObject.cpp b/lib/Support/MemoryObject.cpp
index c82f46a..b20ab89 100644
--- a/lib/Support/MemoryObject.cpp
+++ b/lib/Support/MemoryObject.cpp
@@ -16,7 +16,7 @@ MemoryObject::~MemoryObject() {
int MemoryObject::readBytes(uint64_t address,
uint64_t size,
uint8_t* buf,
- uint64_t* copied) {
+ uint64_t* copied) const {
uint64_t current = address;
uint64_t limit = getBase() + getExtent();
diff --git a/lib/Support/StreamableMemoryObject.cpp b/lib/Support/StreamableMemoryObject.cpp
index 0f2acb4..c23f07b 100644
--- a/lib/Support/StreamableMemoryObject.cpp
+++ b/lib/Support/StreamableMemoryObject.cpp
@@ -24,15 +24,17 @@ public:
}
virtual uint64_t getBase() const { return 0; }
- virtual uint64_t getExtent() { return LastChar - FirstChar; }
- virtual int readByte(uint64_t address, uint8_t* ptr);
+ virtual uint64_t getExtent() const { return LastChar - FirstChar; }
+ virtual int readByte(uint64_t address, uint8_t* ptr) const;
virtual int readBytes(uint64_t address,
uint64_t size,
uint8_t* buf,
- uint64_t* copied);
- virtual const uint8_t *getPointer(uint64_t address, uint64_t size);
- virtual bool isValidAddress(uint64_t address) {return validAddress(address);}
- virtual bool isObjectEnd(uint64_t address) {return objectEnd(address);}
+ uint64_t* copied) const;
+ virtual const uint8_t *getPointer(uint64_t address, uint64_t size) const;
+ virtual bool isValidAddress(uint64_t address) const {
+ return validAddress(address);
+ }
+ virtual bool isObjectEnd(uint64_t address) const {return objectEnd(address);}
private:
const uint8_t* const FirstChar;
@@ -40,10 +42,10 @@ private:
// These are implemented as inline functions here to avoid multiple virtual
// calls per public function
- bool validAddress(uint64_t address) {
+ bool validAddress(uint64_t address) const {
return static_cast<ptrdiff_t>(address) < LastChar - FirstChar;
}
- bool objectEnd(uint64_t address) {
+ bool objectEnd(uint64_t address) const {
return static_cast<ptrdiff_t>(address) == LastChar - FirstChar;
}
@@ -51,7 +53,7 @@ private:
void operator=(const RawMemoryObject&); // DO NOT IMPLEMENT
};
-int RawMemoryObject::readByte(uint64_t address, uint8_t* ptr) {
+int RawMemoryObject::readByte(uint64_t address, uint8_t* ptr) const {
if (!validAddress(address)) return -1;
*ptr = *((uint8_t *)(uintptr_t)(address + FirstChar));
return 0;
@@ -60,14 +62,15 @@ int RawMemoryObject::readByte(uint64_t address, uint8_t* ptr) {
int RawMemoryObject::readBytes(uint64_t address,
uint64_t size,
uint8_t* buf,
- uint64_t* copied) {
+ uint64_t* copied) const {
if (!validAddress(address) || !validAddress(address + size - 1)) return -1;
memcpy(buf, (uint8_t *)(uintptr_t)(address + FirstChar), size);
if (copied) *copied = size;
return size;
}
-const uint8_t *RawMemoryObject::getPointer(uint64_t address, uint64_t size) {
+const uint8_t *RawMemoryObject::getPointer(uint64_t address,
+ uint64_t size) const {
return FirstChar + address;
}
} // anonymous namespace
@@ -75,18 +78,18 @@ const uint8_t *RawMemoryObject::getPointer(uint64_t address, uint64_t size) {
namespace llvm {
// If the bitcode has a header, then its size is known, and we don't have to
// block until we actually want to read it.
-bool StreamingMemoryObject::isValidAddress(uint64_t address) {
+bool StreamingMemoryObject::isValidAddress(uint64_t address) const {
if (ObjectSize && address < ObjectSize) return true;
return fetchToPos(address);
}
-bool StreamingMemoryObject::isObjectEnd(uint64_t address) {
+bool StreamingMemoryObject::isObjectEnd(uint64_t address) const {
if (ObjectSize) return address == ObjectSize;
fetchToPos(address);
return address == ObjectSize && address != 0;
}
-uint64_t StreamingMemoryObject::getExtent() {
+uint64_t StreamingMemoryObject::getExtent() const {
if (ObjectSize) return ObjectSize;
size_t pos = BytesRead + kChunkSize;
// keep fetching until we run out of bytes
@@ -94,7 +97,7 @@ uint64_t StreamingMemoryObject::getExtent() {
return ObjectSize;
}
-int StreamingMemoryObject::readByte(uint64_t address, uint8_t* ptr) {
+int StreamingMemoryObject::readByte(uint64_t address, uint8_t* ptr) const {
if (!fetchToPos(address)) return -1;
*ptr = Bytes[address + BytesSkipped];
return 0;
@@ -103,7 +106,7 @@ int StreamingMemoryObject::readByte(uint64_t address, uint8_t* ptr) {
int StreamingMemoryObject::readBytes(uint64_t address,
uint64_t size,
uint8_t* buf,
- uint64_t* copied) {
+ uint64_t* copied) const {
if (!fetchToPos(address + size - 1)) return -1;
memcpy(buf, &Bytes[address + BytesSkipped], size);
if (copied) *copied = size;