llvm-6502/lib/MC/MCDisassembler.cpp
Ahmed Charles f4ccd11075 Replace OwningPtr<T> with std::unique_ptr<T>.
This compiles with no changes to clang/lld/lldb with MSVC and includes
overloads to various functions which are used by those projects and llvm
which have OwningPtr's as parameters. This should allow out of tree
projects some time to move. There are also no changes to libs/Target,
which should help out of tree targets have time to move, if necessary.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@203083 91177308-0d34-0410-b5e6-96231b3b80d8
2014-03-06 05:51:42 +00:00

61 lines
2.3 KiB
C++

//===-- lib/MC/MCDisassembler.cpp - Disassembler interface ------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#include "llvm/MC/MCDisassembler.h"
#include "llvm/MC/MCExternalSymbolizer.h"
#include "llvm/Support/raw_ostream.h"
using namespace llvm;
MCDisassembler::~MCDisassembler() {
}
void MCDisassembler::setupForSymbolicDisassembly(
LLVMOpInfoCallback GetOpInfo, LLVMSymbolLookupCallback SymbolLookUp,
void *DisInfo, MCContext *Ctx, std::unique_ptr<MCRelocationInfo> &RelInfo) {
this->GetOpInfo = GetOpInfo;
this->SymbolLookUp = SymbolLookUp;
this->DisInfo = DisInfo;
this->Ctx = Ctx;
assert(Ctx != 0 && "No MCContext given for symbolic disassembly");
if (!Symbolizer)
Symbolizer.reset(new MCExternalSymbolizer(*Ctx, RelInfo, GetOpInfo,
SymbolLookUp, DisInfo));
}
void MCDisassembler::setupForSymbolicDisassembly(
LLVMOpInfoCallback GetOpInfo, LLVMSymbolLookupCallback SymbolLookUp,
void *DisInfo, MCContext *Ctx, OwningPtr<MCRelocationInfo> &RelInfo) {
std::unique_ptr<MCRelocationInfo> MCRI;
setupForSymbolicDisassembly(GetOpInfo, SymbolLookUp, DisInfo, Ctx, MCRI);
RelInfo = std::move(MCRI);
}
bool MCDisassembler::tryAddingSymbolicOperand(MCInst &Inst, int64_t Value,
uint64_t Address, bool IsBranch,
uint64_t Offset,
uint64_t InstSize) const {
raw_ostream &cStream = CommentStream ? *CommentStream : nulls();
if (Symbolizer)
return Symbolizer->tryAddingSymbolicOperand(Inst, cStream, Value, Address,
IsBranch, Offset, InstSize);
return false;
}
void MCDisassembler::tryAddingPcLoadReferenceComment(int64_t Value,
uint64_t Address) const {
raw_ostream &cStream = CommentStream ? *CommentStream : nulls();
if (Symbolizer)
Symbolizer->tryAddingPcLoadReferenceComment(cStream, Value, Address);
}
void MCDisassembler::setSymbolizer(std::unique_ptr<MCSymbolizer> &Symzer) {
Symbolizer.reset(Symzer.release());
}