Convert two char* that are only ever used as booleans to bool.
[oota-llvm.git] / lib / MC / MCDisassembler.cpp
1 //===-- lib/MC/MCDisassembler.cpp - Disassembler interface ------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9
10 #include "llvm/MC/MCDisassembler.h"
11 #include "llvm/MC/MCExternalSymbolizer.h"
12 #include "llvm/Support/raw_ostream.h"
13
14 using namespace llvm;
15
16 MCDisassembler::~MCDisassembler() {
17 }
18
19 void
20 MCDisassembler::setupForSymbolicDisassembly(
21     LLVMOpInfoCallback GetOpInfo,
22     LLVMSymbolLookupCallback SymbolLookUp,
23     void *DisInfo,
24     MCContext *Ctx,
25     OwningPtr<MCRelocationInfo> &RelInfo) {
26   this->GetOpInfo = GetOpInfo;
27   this->SymbolLookUp = SymbolLookUp;
28   this->DisInfo = DisInfo;
29   this->Ctx = Ctx;
30   assert(Ctx != 0 && "No MCContext given for symbolic disassembly");
31   if (!Symbolizer)
32     Symbolizer.reset(new MCExternalSymbolizer(*Ctx, RelInfo, GetOpInfo,
33                                               SymbolLookUp, DisInfo));
34 }
35
36 bool MCDisassembler::tryAddingSymbolicOperand(MCInst &Inst, int64_t Value,
37                                               uint64_t Address, bool IsBranch,
38                                               uint64_t Offset,
39                                               uint64_t InstSize) const {
40   raw_ostream &cStream = CommentStream ? *CommentStream : nulls();
41   if (Symbolizer)
42     return Symbolizer->tryAddingSymbolicOperand(Inst, cStream, Value, Address,
43                                                 IsBranch, Offset, InstSize);
44   return false;
45 }
46
47 void MCDisassembler::tryAddingPcLoadReferenceComment(int64_t Value,
48                                                      uint64_t Address) const {
49   raw_ostream &cStream = CommentStream ? *CommentStream : nulls();
50   if (Symbolizer)
51     Symbolizer->tryAddingPcLoadReferenceComment(cStream, Value, Address);
52 }
53
54 void MCDisassembler::setSymbolizer(OwningPtr<MCSymbolizer> &Symzer) {
55   Symbolizer.reset(Symzer.take());
56 }