Fix apparent build error caused by r138948 on certain versions of GCC with -Werror. Sorry for the inconvenience.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@138973 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
James Molloy 2011-09-01 22:01:14 +00:00
parent 6bb4e7e8e8
commit ee06443945
2 changed files with 39 additions and 24 deletions

View File

@ -135,21 +135,28 @@ size_t LLVMDisasmInstruction(LLVMDisasmContextRef DCR, uint8_t *Bytes,
MCInst Inst;
const MCDisassembler *DisAsm = DC->getDisAsm();
MCInstPrinter *IP = DC->getIP();
if (DisAsm->getInstruction(Inst, Size, MemoryObject, PC,
/*REMOVE*/ nulls()) != MCDisassembler::Success) {
MCDisassembler::DecodeStatus S;
S = DisAsm->getInstruction(Inst, Size, MemoryObject, PC,
/*REMOVE*/ nulls());
switch (S) {
case MCDisassembler::Fail:
case MCDisassembler::SoftFail:
// FIXME: Do something different for soft failure modes?
return 0;
case MCDisassembler::Success: {
SmallVector<char, 64> InsnStr;
raw_svector_ostream OS(InsnStr);
IP->printInst(&Inst, OS);
OS.flush();
assert(OutStringSize != 0 && "Output buffer cannot be zero size");
size_t OutputSize = std::min(OutStringSize-1, InsnStr.size());
std::memcpy(OutString, InsnStr.data(), OutputSize);
OutString[OutputSize] = '\0'; // Terminate string.
return Size;
}
SmallVector<char, 64> InsnStr;
raw_svector_ostream OS(InsnStr);
IP->printInst(&Inst, OS);
OS.flush();
assert(OutStringSize != 0 && "Output buffer cannot be zero size");
size_t OutputSize = std::min(OutStringSize-1, InsnStr.size());
std::memcpy(OutString, InsnStr.data(), OutputSize);
OutString[OutputSize] = '\0'; // Terminate string.
return Size;
}
return 0;
}

View File

@ -239,20 +239,28 @@ EDInst *EDDisassembler::createInst(EDByteReaderCallback byteReader,
MCInst* inst = new MCInst;
uint64_t byteSize;
if (Disassembler->getInstruction(*inst, byteSize, memoryObject, address,
ErrorStream) != MCDisassembler::Success) {
MCDisassembler::DecodeStatus S;
S = Disassembler->getInstruction(*inst, byteSize, memoryObject, address,
ErrorStream);
switch (S) {
case MCDisassembler::Fail:
case MCDisassembler::SoftFail:
// FIXME: Do something different on soft failure mode?
delete inst;
return NULL;
}
const llvm::EDInstInfo *thisInstInfo = NULL;
if (InstInfos) {
thisInstInfo = &InstInfos[inst->getOpcode()];
}
EDInst* sdInst = new EDInst(inst, byteSize, *this, thisInstInfo);
return sdInst;
case MCDisassembler::Success: {
const llvm::EDInstInfo *thisInstInfo = NULL;
if (InstInfos) {
thisInstInfo = &InstInfos[inst->getOpcode()];
}
EDInst* sdInst = new EDInst(inst, byteSize, *this, thisInstInfo);
return sdInst;
}
}
return NULL;
}
void EDDisassembler::initMaps(const MCRegisterInfo &registerInfo) {