diff options
author | John Hodge <tpg@ucc.asn.au> | 2017-03-11 22:54:55 +0800 |
---|---|---|
committer | John Hodge <tpg@ucc.asn.au> | 2017-03-11 22:54:55 +0800 |
commit | 9540cf3642abaf41c8d4c89eaee8a0d72f2dcf1d (patch) | |
tree | 97a2661524e353d6a8c460fa2d23e927056ab1d2 /src/mir/dump.cpp | |
parent | 89b40c78c9e96a32043cb12380777a5ccd13a4a1 (diff) | |
download | mrust-9540cf3642abaf41c8d4c89eaee8a0d72f2dcf1d.tar.gz |
MIR Dump - Fix bad printing of byte string literals
Diffstat (limited to 'src/mir/dump.cpp')
-rw-r--r-- | src/mir/dump.cpp | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/src/mir/dump.cpp b/src/mir/dump.cpp index f3dee478..eb74dc9e 100644 --- a/src/mir/dump.cpp +++ b/src/mir/dump.cpp @@ -9,6 +9,7 @@ #include <hir/visitor.hpp> #include "mir.hpp" #include "operations.hpp" +#include <iomanip> namespace { @@ -208,7 +209,19 @@ namespace { os << (ce.v ? "true" : "false"); ), (Bytes, - os << "b\"" << ce << "\""; + os << ::std::hex << "b\""; + for(auto b : ce) + { + if( b == '\\' ) + os << "\\\\"; + else if( b == '"' ) + os << "\\\""; + else if( ' ' <= b && b < 0x7F ) + os << b; + else + os << "\\x" << ::std::setw(2) << ::std::setfill('0') << (int)b; + } + os << ::std::dec << "\""; ), (StaticString, os << "\"" << ce << "\""; |