[llvm] r211961 - [RuntimeDyld] Use a raw_ostream and llvm::format for int-to-string conversions.

Lang Hames lhames at gmail.com
Fri Jun 27 14:07:01 PDT 2014


Author: lhames
Date: Fri Jun 27 16:07:00 2014
New Revision: 211961

URL: http://llvm.org/viewvc/llvm-project?rev=211961&view=rev
Log:
[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.


Modified:
    llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldChecker.cpp

Modified: llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldChecker.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldChecker.cpp?rev=211961&r1=211960&r2=211961&view=diff
==============================================================================
--- llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldChecker.cpp (original)
+++ llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldChecker.cpp Fri Jun 27 16:07:00 2014
@@ -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);





More information about the llvm-commits mailing list