summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/llvm/Bitcode/BitstreamReader.h5
-rw-r--r--include/llvm/Support/MemoryObject.h11
-rw-r--r--include/llvm/Support/StreamableMemoryObject.h18
-rw-r--r--include/llvm/Support/StringRefMemoryObject.h11
-rw-r--r--lib/Bitcode/Reader/BitcodeReader.cpp2
-rw-r--r--lib/Support/MemoryObject.cpp6
-rw-r--r--lib/Support/StreamableMemoryObject.cpp11
-rw-r--r--lib/Support/StringRefMemoryObject.cpp11
-rw-r--r--lib/Target/AArch64/Disassembler/AArch64Disassembler.cpp2
-rw-r--r--lib/Target/ARM/Disassembler/ARMDisassembler.cpp6
-rw-r--r--lib/Target/MBlaze/Disassembler/MBlazeDisassembler.cpp3
-rw-r--r--lib/Target/Mips/Disassembler/MipsDisassembler.cpp2
-rw-r--r--lib/Target/SystemZ/Disassembler/SystemZDisassembler.cpp4
-rw-r--r--lib/Target/XCore/Disassembler/XCoreDisassembler.cpp4
14 files changed, 35 insertions, 61 deletions
diff --git a/include/llvm/Bitcode/BitstreamReader.h b/include/llvm/Bitcode/BitstreamReader.h
index f3139739cd..dc5e095155 100644
--- a/include/llvm/Bitcode/BitstreamReader.h
+++ b/include/llvm/Bitcode/BitstreamReader.h
@@ -244,7 +244,7 @@ public:
uint32_t getWord(size_t pos) {
uint8_t buf[4] = { 0xFF, 0xFF, 0xFF, 0xFF };
- BitStream->getBitcodeBytes().readBytes(pos, sizeof(buf), buf, NULL);
+ BitStream->getBitcodeBytes().readBytes(pos, sizeof(buf), buf);
return *reinterpret_cast<support::ulittle32_t *>(buf);
}
@@ -366,8 +366,7 @@ public:
// Read the next word from the stream.
uint8_t Array[sizeof(word_t)] = {0};
- BitStream->getBitcodeBytes().readBytes(NextChar, sizeof(Array),
- Array, NULL);
+ BitStream->getBitcodeBytes().readBytes(NextChar, sizeof(Array), Array);
// Handle big-endian byte-swapping if necessary.
support::detail::packed_endian_specific_integral
diff --git a/include/llvm/Support/MemoryObject.h b/include/llvm/Support/MemoryObject.h
index 732b0f0774..17aa9d2f67 100644
--- a/include/llvm/Support/MemoryObject.h
+++ b/include/llvm/Support/MemoryObject.h
@@ -42,7 +42,7 @@ public:
/// @param ptr - A pointer to a byte to be filled in. Must be non-NULL.
/// @result - 0 if successful; -1 if not. Failure may be due to a
/// bounds violation or an implementation-specific error.
- virtual int readByte(uint64_t address, uint8_t* ptr) const = 0;
+ virtual int readByte(uint64_t address, uint8_t *ptr) const = 0;
/// readBytes - Tries to read a contiguous range of bytes from the
/// region, up to the end of the region.
@@ -51,17 +51,12 @@ public:
///
/// @param address - The address of the first byte, in the same space as
/// getBase().
- /// @param size - The maximum number of bytes to copy.
+ /// @param size - The number of bytes to copy.
/// @param buf - A pointer to a buffer to be filled in. Must be non-NULL
/// and large enough to hold size bytes.
- /// @param copied - A pointer to a nunber that is filled in with the number
- /// of bytes actually read. May be NULL.
/// @result - 0 if successful; -1 if not. Failure may be due to a
/// bounds violation or an implementation-specific error.
- virtual int readBytes(uint64_t address,
- uint64_t size,
- uint8_t* buf,
- uint64_t* copied) const;
+ virtual int readBytes(uint64_t address, uint64_t size, uint8_t *buf) const;
};
}
diff --git a/include/llvm/Support/StreamableMemoryObject.h b/include/llvm/Support/StreamableMemoryObject.h
index 385548579b..e823d489d3 100644
--- a/include/llvm/Support/StreamableMemoryObject.h
+++ b/include/llvm/Support/StreamableMemoryObject.h
@@ -38,7 +38,7 @@ class StreamableMemoryObject : public MemoryObject {
/// getBase - Returns the lowest valid address in the region.
///
/// @result - The lowest valid address.
- virtual uint64_t getBase() const = 0;
+ virtual uint64_t getBase() const LLVM_OVERRIDE = 0;
/// getExtent - Returns the size of the region in bytes. (The region is
/// contiguous, so the highest valid address of the region
@@ -46,7 +46,7 @@ class StreamableMemoryObject : public MemoryObject {
/// May block until all bytes in the stream have been read
///
/// @result - The size of the region.
- virtual uint64_t getExtent() const = 0;
+ virtual uint64_t getExtent() const LLVM_OVERRIDE = 0;
/// readByte - Tries to read a single byte from the region.
/// May block until (address - base) bytes have been read
@@ -54,7 +54,7 @@ class StreamableMemoryObject : public MemoryObject {
/// @param ptr - A pointer to a byte to be filled in. Must be non-NULL.
/// @result - 0 if successful; -1 if not. Failure may be due to a
/// bounds violation or an implementation-specific error.
- virtual int readByte(uint64_t address, uint8_t* ptr) const = 0;
+ virtual int readByte(uint64_t address, uint8_t *ptr) const LLVM_OVERRIDE = 0;
/// readBytes - Tries to read a contiguous range of bytes from the
/// region, up to the end of the region.
@@ -65,17 +65,14 @@ class StreamableMemoryObject : public MemoryObject {
///
/// @param address - The address of the first byte, in the same space as
/// getBase().
- /// @param size - The maximum number of bytes to copy.
+ /// @param size - The number of bytes to copy.
/// @param buf - A pointer to a buffer to be filled in. Must be non-NULL
/// and large enough to hold size bytes.
- /// @param copied - A pointer to a nunber that is filled in with the number
- /// of bytes actually read. May be NULL.
/// @result - 0 if successful; -1 if not. Failure may be due to a
/// bounds violation or an implementation-specific error.
virtual int readBytes(uint64_t address,
uint64_t size,
- uint8_t* buf,
- uint64_t* copied) const = 0;
+ uint8_t *buf) const LLVM_OVERRIDE = 0;
/// getPointer - Ensures that the requested data is in memory, and returns
/// A pointer to it. More efficient than using readBytes if the
@@ -110,11 +107,10 @@ public:
StreamingMemoryObject(DataStreamer *streamer);
virtual uint64_t getBase() const LLVM_OVERRIDE { return 0; }
virtual uint64_t getExtent() const LLVM_OVERRIDE;
- virtual int readByte(uint64_t address, uint8_t* ptr) const LLVM_OVERRIDE;
+ virtual int readByte(uint64_t address, uint8_t *ptr) const LLVM_OVERRIDE;
virtual int readBytes(uint64_t address,
uint64_t size,
- uint8_t* buf,
- uint64_t* copied) const LLVM_OVERRIDE;
+ uint8_t *buf) const LLVM_OVERRIDE;
virtual const uint8_t *getPointer(uint64_t address,
uint64_t size) const LLVM_OVERRIDE {
// This could be fixed by ensuring the bytes are fetched and making a copy,
diff --git a/include/llvm/Support/StringRefMemoryObject.h b/include/llvm/Support/StringRefMemoryObject.h
index a0ef35a9e1..994fa34b74 100644
--- a/include/llvm/Support/StringRefMemoryObject.h
+++ b/include/llvm/Support/StringRefMemoryObject.h
@@ -16,6 +16,7 @@
#define LLVM_SUPPORT_STRINGREFMEMORYOBJECT_H
#include "llvm/ADT/StringRef.h"
+#include "llvm/Support/Compiler.h"
#include "llvm/Support/MemoryObject.h"
namespace llvm {
@@ -28,13 +29,11 @@ public:
StringRefMemoryObject(StringRef Bytes, uint64_t Base = 0)
: Bytes(Bytes), Base(Base) {}
- uint64_t getBase() const { return Base; }
- uint64_t getExtent() const { return Bytes.size(); }
-
- int readByte(uint64_t Addr, uint8_t *Byte) const;
- int readBytes(uint64_t Addr, uint64_t Size,
- uint8_t *Buf, uint64_t *Copied) const;
+ uint64_t getBase() const LLVM_OVERRIDE { return Base; }
+ uint64_t getExtent() const LLVM_OVERRIDE { return Bytes.size(); }
+ int readByte(uint64_t Addr, uint8_t *Byte) const LLVM_OVERRIDE;
+ int readBytes(uint64_t Addr, uint64_t Size, uint8_t *Buf) const LLVM_OVERRIDE;
};
}
diff --git a/lib/Bitcode/Reader/BitcodeReader.cpp b/lib/Bitcode/Reader/BitcodeReader.cpp
index e6ff4b43b1..cf827c5d4b 100644
--- a/lib/Bitcode/Reader/BitcodeReader.cpp
+++ b/lib/Bitcode/Reader/BitcodeReader.cpp
@@ -3010,7 +3010,7 @@ bool BitcodeReader::InitLazyStream() {
Stream.init(*StreamFile);
unsigned char buf[16];
- if (Bytes->readBytes(0, 16, buf, NULL) == -1)
+ if (Bytes->readBytes(0, 16, buf) == -1)
return Error("Bitcode stream must be at least 16 bytes in length");
if (!isBitcode(buf, buf + 16))
diff --git a/lib/Support/MemoryObject.cpp b/lib/Support/MemoryObject.cpp
index b20ab89238..02b5b5034f 100644
--- a/lib/Support/MemoryObject.cpp
+++ b/lib/Support/MemoryObject.cpp
@@ -15,8 +15,7 @@ MemoryObject::~MemoryObject() {
int MemoryObject::readBytes(uint64_t address,
uint64_t size,
- uint8_t* buf,
- uint64_t* copied) const {
+ uint8_t* buf) const {
uint64_t current = address;
uint64_t limit = getBase() + getExtent();
@@ -30,8 +29,5 @@ int MemoryObject::readBytes(uint64_t address,
current++;
}
- if (copied)
- *copied = current - address;
-
return 0;
}
diff --git a/lib/Support/StreamableMemoryObject.cpp b/lib/Support/StreamableMemoryObject.cpp
index 59e27a263e..2ed7c5c100 100644
--- a/lib/Support/StreamableMemoryObject.cpp
+++ b/lib/Support/StreamableMemoryObject.cpp
@@ -31,8 +31,7 @@ public:
virtual int readByte(uint64_t address, uint8_t* ptr) const LLVM_OVERRIDE;
virtual int readBytes(uint64_t address,
uint64_t size,
- uint8_t* buf,
- uint64_t* copied) const LLVM_OVERRIDE;
+ uint8_t *buf) const LLVM_OVERRIDE;
virtual const uint8_t *getPointer(uint64_t address,
uint64_t size) const LLVM_OVERRIDE;
virtual bool isValidAddress(uint64_t address) const LLVM_OVERRIDE {
@@ -67,11 +66,9 @@ int RawMemoryObject::readByte(uint64_t address, uint8_t* ptr) const {
int RawMemoryObject::readBytes(uint64_t address,
uint64_t size,
- uint8_t* buf,
- uint64_t* copied) const {
+ uint8_t *buf) 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;
}
@@ -111,11 +108,9 @@ int StreamingMemoryObject::readByte(uint64_t address, uint8_t* ptr) const {
int StreamingMemoryObject::readBytes(uint64_t address,
uint64_t size,
- uint8_t* buf,
- uint64_t* copied) const {
+ uint8_t *buf) const {
if (!fetchToPos(address + size - 1)) return -1;
memcpy(buf, &Bytes[address + BytesSkipped], size);
- if (copied) *copied = size;
return 0;
}
diff --git a/lib/Support/StringRefMemoryObject.cpp b/lib/Support/StringRefMemoryObject.cpp
index 5db11e918c..e035ed1d2e 100644
--- a/lib/Support/StringRefMemoryObject.cpp
+++ b/lib/Support/StringRefMemoryObject.cpp
@@ -20,15 +20,10 @@ int StringRefMemoryObject::readByte(uint64_t Addr, uint8_t *Byte) const {
int StringRefMemoryObject::readBytes(uint64_t Addr,
uint64_t Size,
- uint8_t *Buf,
- uint64_t *Copied) const {
- if (Addr >= Base + getExtent() || Addr < Base)
- return -1;
+ uint8_t *Buf) const {
uint64_t Offset = Addr - Base;
- if (Size > getExtent() - Offset)
- Size = getExtent() - Offset;
+ if (Addr >= Base + getExtent() || Offset + Size > getExtent() || Addr < Base)
+ return -1;
memcpy(Buf, Bytes.data() + Offset, Size);
- if (Copied)
- *Copied = Size;
return 0;
}
diff --git a/lib/Target/AArch64/Disassembler/AArch64Disassembler.cpp b/lib/Target/AArch64/Disassembler/AArch64Disassembler.cpp
index 12c1b8f4c8..1c397b5fa9 100644
--- a/lib/Target/AArch64/Disassembler/AArch64Disassembler.cpp
+++ b/lib/Target/AArch64/Disassembler/AArch64Disassembler.cpp
@@ -208,7 +208,7 @@ DecodeStatus AArch64Disassembler::getInstruction(MCInst &MI, uint64_t &Size,
uint8_t bytes[4];
// We want to read exactly 4 bytes of data.
- if (Region.readBytes(Address, 4, (uint8_t*)bytes, NULL) == -1) {
+ if (Region.readBytes(Address, 4, bytes) == -1) {
Size = 0;
return MCDisassembler::Fail;
}
diff --git a/lib/Target/ARM/Disassembler/ARMDisassembler.cpp b/lib/Target/ARM/Disassembler/ARMDisassembler.cpp
index 284761cf29..0a7d5eeb87 100644
--- a/lib/Target/ARM/Disassembler/ARMDisassembler.cpp
+++ b/lib/Target/ARM/Disassembler/ARMDisassembler.cpp
@@ -413,7 +413,7 @@ DecodeStatus ARMDisassembler::getInstruction(MCInst &MI, uint64_t &Size,
"Asked to disassemble an ARM instruction but Subtarget is in Thumb mode!");
// We want to read exactly 4 bytes of data.
- if (Region.readBytes(Address, 4, (uint8_t*)bytes, NULL) == -1) {
+ if (Region.readBytes(Address, 4, bytes) == -1) {
Size = 0;
return MCDisassembler::Fail;
}
@@ -659,7 +659,7 @@ DecodeStatus ThumbDisassembler::getInstruction(MCInst &MI, uint64_t &Size,
"Asked to disassemble in Thumb mode but Subtarget is in ARM mode!");
// We want to read exactly 2 bytes of data.
- if (Region.readBytes(Address, 2, (uint8_t*)bytes, NULL) == -1) {
+ if (Region.readBytes(Address, 2, bytes) == -1) {
Size = 0;
return MCDisassembler::Fail;
}
@@ -711,7 +711,7 @@ DecodeStatus ThumbDisassembler::getInstruction(MCInst &MI, uint64_t &Size,
}
// We want to read exactly 4 bytes of data.
- if (Region.readBytes(Address, 4, (uint8_t*)bytes, NULL) == -1) {
+ if (Region.readBytes(Address, 4, bytes) == -1) {
Size = 0;
return MCDisassembler::Fail;
}
diff --git a/lib/Target/MBlaze/Disassembler/MBlazeDisassembler.cpp b/lib/Target/MBlaze/Disassembler/MBlazeDisassembler.cpp
index c03ab3803b..0acfb3ec2a 100644
--- a/lib/Target/MBlaze/Disassembler/MBlazeDisassembler.cpp
+++ b/lib/Target/MBlaze/Disassembler/MBlazeDisassembler.cpp
@@ -501,14 +501,13 @@ MCDisassembler::DecodeStatus MBlazeDisassembler::getInstruction(MCInst &instr,
raw_ostream &cStream) const {
// The machine instruction.
uint32_t insn;
- uint64_t read;
uint8_t bytes[4];
// By default we consume 1 byte on failure
size = 1;
// We want to read exactly 4 bytes of data.
- if (region.readBytes(address, 4, (uint8_t*)bytes, &read) == -1 || read < 4)
+ if (region.readBytes(address, 4, bytes) == -1)
return Fail;
// Encoded as a big-endian 32-bit word in the stream.
diff --git a/lib/Target/Mips/Disassembler/MipsDisassembler.cpp b/lib/Target/Mips/Disassembler/MipsDisassembler.cpp
index 0dba33a276..4af67037e9 100644
--- a/lib/Target/Mips/Disassembler/MipsDisassembler.cpp
+++ b/lib/Target/Mips/Disassembler/MipsDisassembler.cpp
@@ -252,7 +252,7 @@ static DecodeStatus readInstruction32(const MemoryObject &region,
uint8_t Bytes[4];
// We want to read exactly 4 Bytes of data.
- if (region.readBytes(address, 4, (uint8_t*)Bytes, NULL) == -1) {
+ if (region.readBytes(address, 4, Bytes) == -1) {
size = 0;
return MCDisassembler::Fail;
}
diff --git a/lib/Target/SystemZ/Disassembler/SystemZDisassembler.cpp b/lib/Target/SystemZ/Disassembler/SystemZDisassembler.cpp
index 9a9de78224..4e4816bada 100644
--- a/lib/Target/SystemZ/Disassembler/SystemZDisassembler.cpp
+++ b/lib/Target/SystemZ/Disassembler/SystemZDisassembler.cpp
@@ -272,7 +272,7 @@ DecodeStatus SystemZDisassembler::getInstruction(MCInst &MI, uint64_t &Size,
// Get the first two bytes of the instruction.
uint8_t Bytes[6];
Size = 0;
- if (Region.readBytes(Address, 2, Bytes, 0) == -1)
+ if (Region.readBytes(Address, 2, Bytes) == -1)
return MCDisassembler::Fail;
// The top 2 bits of the first byte specify the size.
@@ -289,7 +289,7 @@ DecodeStatus SystemZDisassembler::getInstruction(MCInst &MI, uint64_t &Size,
}
// Read any remaining bytes.
- if (Size > 2 && Region.readBytes(Address + 2, Size - 2, Bytes + 2, 0) == -1)
+ if (Size > 2 && Region.readBytes(Address + 2, Size - 2, Bytes + 2) == -1)
return MCDisassembler::Fail;
// Construct the instruction.
diff --git a/lib/Target/XCore/Disassembler/XCoreDisassembler.cpp b/lib/Target/XCore/Disassembler/XCoreDisassembler.cpp
index a2ae40c58a..dcc0955028 100644
--- a/lib/Target/XCore/Disassembler/XCoreDisassembler.cpp
+++ b/lib/Target/XCore/Disassembler/XCoreDisassembler.cpp
@@ -53,7 +53,7 @@ static bool readInstruction16(const MemoryObject &region,
uint8_t Bytes[4];
// We want to read exactly 2 Bytes of data.
- if (region.readBytes(address, 2, Bytes, NULL) == -1) {
+ if (region.readBytes(address, 2, Bytes) == -1) {
size = 0;
return false;
}
@@ -69,7 +69,7 @@ static bool readInstruction32(const MemoryObject &region,
uint8_t Bytes[4];
// We want to read exactly 4 Bytes of data.
- if (region.readBytes(address, 4, Bytes, NULL) == -1) {
+ if (region.readBytes(address, 4, Bytes) == -1) {
size = 0;
return false;
}