1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-24 11:42:57 +01:00
llvm-mirror/lib/Support/StringRefMemoryObject.cpp
Benjamin Kramer fcb0899e18 Remove the Copied parameter from MemoryObject::readBytes.
There was exactly one caller using this API right, the others were relying on
specific behavior of the default implementation. Since it's too hard to use it
right just remove it and standardize on the default behavior.

Defines away PR16132.

llvm-svn: 182636
2013-05-24 10:54:58 +00:00

30 lines
946 B
C++

//===- lib/Support/StringRefMemoryObject.cpp --------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#include "llvm/Support/StringRefMemoryObject.h"
using namespace llvm;
int StringRefMemoryObject::readByte(uint64_t Addr, uint8_t *Byte) const {
if (Addr >= Base + getExtent() || Addr < Base)
return -1;
*Byte = Bytes[Addr - Base];
return 0;
}
int StringRefMemoryObject::readBytes(uint64_t Addr,
uint64_t Size,
uint8_t *Buf) const {
uint64_t Offset = Addr - Base;
if (Addr >= Base + getExtent() || Offset + Size > getExtent() || Addr < Base)
return -1;
memcpy(Buf, Bytes.data() + Offset, Size);
return 0;
}