summaryrefslogtreecommitdiff
path: root/src/passes/Print.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/passes/Print.cpp')
-rw-r--r--src/passes/Print.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/passes/Print.cpp b/src/passes/Print.cpp
index ad4d20bae..20c585859 100644
--- a/src/passes/Print.cpp
+++ b/src/passes/Print.cpp
@@ -2122,6 +2122,25 @@ struct PrintSExpression : public OverriddenVisitor<PrintSExpression> {
doIndent(o, indent);
o << ";; custom section \"" << section.name << "\", size "
<< section.data.size();
+ bool isPrintable = true;
+ for (auto c : section.data) {
+ if (!isprint(c)) {
+ isPrintable = false;
+ break;
+ }
+ }
+ if (isPrintable) {
+ o << ", contents: ";
+ // std::quoted is not available in all the supported compilers yet.
+ o << '"';
+ for (auto c : section.data) {
+ if (c == '\\' || c == '"') {
+ o << '\\';
+ }
+ o << c;
+ }
+ o << '"';
+ }
o << maybeNewLine;
}
decIndent();