summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJames Molloy <james.molloy@arm.com>2011-09-01 22:01:14 +0000
committerJames Molloy <james.molloy@arm.com>2011-09-01 22:01:14 +0000
commitee06443945b4c9f471c9b80c4325075dbc27746e (patch)
tree56202c2704bf286723a233f737e189fbcc78a8ae /lib
parent6bb4e7e8e8c39432c890bedb800bb01f6eda1e44 (diff)
downloadllvm-ee06443945b4c9f471c9b80c4325075dbc27746e.tar.gz
llvm-ee06443945b4c9f471c9b80c4325075dbc27746e.tar.bz2
llvm-ee06443945b4c9f471c9b80c4325075dbc27746e.tar.xz
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
Diffstat (limited to 'lib')
-rw-r--r--lib/MC/MCDisassembler/Disassembler.cpp31
-rw-r--r--lib/MC/MCDisassembler/EDDisassembler.cpp26
2 files changed, 36 insertions, 21 deletions
diff --git a/lib/MC/MCDisassembler/Disassembler.cpp b/lib/MC/MCDisassembler/Disassembler.cpp
index 87d8ca8679..603df94f99 100644
--- a/lib/MC/MCDisassembler/Disassembler.cpp
+++ b/lib/MC/MCDisassembler/Disassembler.cpp
@@ -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;
- }
- SmallVector<char, 64> InsnStr;
- raw_svector_ostream OS(InsnStr);
- IP->printInst(&Inst, OS);
- OS.flush();
+ 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.
+ 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 Size;
+ }
+ }
+ return 0;
}
diff --git a/lib/MC/MCDisassembler/EDDisassembler.cpp b/lib/MC/MCDisassembler/EDDisassembler.cpp
index 14d735dbc7..68a201b96a 100644
--- a/lib/MC/MCDisassembler/EDDisassembler.cpp
+++ b/lib/MC/MCDisassembler/EDDisassembler.cpp
@@ -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;
+
+ case MCDisassembler::Success: {
+ const llvm::EDInstInfo *thisInstInfo = NULL;
- if (InstInfos) {
- thisInstInfo = &InstInfos[inst->getOpcode()];
- }
+ if (InstInfos) {
+ thisInstInfo = &InstInfos[inst->getOpcode()];
+ }
- EDInst* sdInst = new EDInst(inst, byteSize, *this, thisInstInfo);
- return sdInst;
+ EDInst* sdInst = new EDInst(inst, byteSize, *this, thisInstInfo);
+ return sdInst;
+ }
+ }
+ return NULL;
}
void EDDisassembler::initMaps(const MCRegisterInfo &registerInfo) {