From a677ffeb959e5a49e9a62d652866ceb07b0173a6 Mon Sep 17 00:00:00 2001 From: Lang Hames Date: Fri, 27 Jun 2014 21:07:00 +0000 Subject: [PATCH] [RuntimeDyld] Use a raw_ostream and llvm::format for int-to-string conversions. Some users' C++11 standard libraries don't support std::to_string yet. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@211961 91177308-0d34-0410-b5e6-96231b3b80d8 --- .../RuntimeDyld/RuntimeDyldChecker.cpp | 34 +++++++++---------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldChecker.cpp b/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldChecker.cpp index c381baf0f5c..190bbbf93ff 100644 --- a/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldChecker.cpp +++ b/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldChecker.cpp @@ -229,28 +229,28 @@ namespace llvm { ""); unsigned OpIdx = OpIdxExpr.getValue(); - if (OpIdx >= Inst.getNumOperands()) - return std::make_pair(EvalResult(("Invalid operand index '" + - std::to_string(OpIdx) + - " for instruction '" + Symbol + - ". Instruction has only " + - std::to_string(Inst.getNumOperands()) - + " operands.").str()), - ""); + if (OpIdx >= Inst.getNumOperands()) { + std::string ErrMsg; + raw_string_ostream ErrMsgStream(ErrMsg); + ErrMsgStream << "Invalid operand index '" << format("%i", OpIdx) + << " for instruction '" << Symbol + << ". Instruction has only " + << format("%i", Inst.getNumOperands()) << " operands."; + return std::make_pair(EvalResult(ErrMsgStream.str()), ""); + } const MCOperand &Op = Inst.getOperand(OpIdx); if (!Op.isImm()) { - std::string InstrString; - raw_string_ostream InstrStringStream(InstrString); - Inst.dump_pretty(InstrStringStream, + std::string ErrMsg; + raw_string_ostream ErrMsgStream(ErrMsg); + ErrMsgStream << "Operand '" << format("%i", OpIdx) + << "' of instruction '" << Symbol + << "' is not an immediate.\nInstruction is:\n "; + Inst.dump_pretty(ErrMsgStream, Checker.Disassembler->getContext().getAsmInfo(), Checker.InstPrinter); - return std::make_pair(EvalResult(("Operand '" + std::to_string(OpIdx) + - "' of instruction '" + Symbol + - "' is not an immediate.\n" - "Instruction is:\n " + - InstrStringStream.str()).str()), - ""); + + return std::make_pair(EvalResult(ErrMsgStream.str()), ""); } return std::make_pair(EvalResult(Op.getImm()), RemainingExpr);