[llvm] r254547 - [Hexagon] Remove std::hex in favor of format().
Alexey Samsonov via llvm-commits
llvm-commits at lists.llvm.org
Wed Dec 2 13:13:44 PST 2015
Author: samsonov
Date: Wed Dec 2 15:13:43 2015
New Revision: 254547
URL: http://llvm.org/viewvc/llvm-project?rev=254547&view=rev
Log:
[Hexagon] Remove std::hex in favor of format().
std::hex is not used anywhere in LLVM code base except for this place,
and it has a known undefined behavior (at least in libstdc++ 4.9.3):
https://llvm.org/bugs/show_bug.cgi?id=18156, which fires in UBSan
bootstrap of LLVM.
Modified:
llvm/trunk/lib/Target/Hexagon/AsmParser/HexagonAsmParser.cpp
Modified: llvm/trunk/lib/Target/Hexagon/AsmParser/HexagonAsmParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Hexagon/AsmParser/HexagonAsmParser.cpp?rev=254547&r1=254546&r2=254547&view=diff
==============================================================================
--- llvm/trunk/lib/Target/Hexagon/AsmParser/HexagonAsmParser.cpp (original)
+++ llvm/trunk/lib/Target/Hexagon/AsmParser/HexagonAsmParser.cpp Wed Dec 2 15:13:43 2015
@@ -38,6 +38,7 @@
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/ELF.h"
+#include "llvm/Support/Format.h"
#include "llvm/Support/SourceMgr.h"
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/TargetRegistry.h"
@@ -1511,14 +1512,15 @@ unsigned HexagonAsmParser::validateTarge
}
void HexagonAsmParser::OutOfRange(SMLoc IDLoc, long long Val, long long Max) {
- std::stringstream errStr;
- errStr << "value " << Val << "(0x" << std::hex << Val << std::dec
+ std::string errStr;
+ raw_string_ostream ES(errStr);
+ ES << "value " << Val << "(" << format("0x%" PRIx64, Val)
<< ") out of range: ";
if (Max >= 0)
- errStr << "0-" << Max;
+ ES << "0-" << Max;
else
- errStr << Max << "-" << (-Max - 1);
- Error(IDLoc, errStr.str().c_str());
+ ES << Max << "-" << (-Max - 1);
+ Error(IDLoc, ES.str().c_str());
}
int HexagonAsmParser::processInstruction(MCInst &Inst,
More information about the llvm-commits
mailing list