summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/trans/mangling.cpp16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/trans/mangling.cpp b/src/trans/mangling.cpp
index 6a175446..9c8c9e56 100644
--- a/src/trans/mangling.cpp
+++ b/src/trans/mangling.cpp
@@ -21,6 +21,16 @@
#include <hir/path.hpp>
namespace {
+ ::std::string escape_str(const ::std::string& s) {
+ ::std::string output;
+ output.reserve(s.size() + 1);
+ for(auto v : s)
+ if( v == '#' )
+ output += "$H";
+ else
+ output += v;
+ return output;
+ }
::FmtLambda emit_params(const ::HIR::PathParams& params)
{
return FMT_CB(ss,
@@ -44,10 +54,8 @@ namespace {
return FMT_CB(ss,
ss << "_ZN" << path.m_path.m_crate_name.size() << path.m_path.m_crate_name;
for(const auto& comp : path.m_path.m_components) {
- if( comp[0] == '#' )
- ss << (comp.size()-1+2) << "$H" << (comp.c_str()+1);
- else
- ss << comp.size() << comp;
+ auto v = escape_str(comp);
+ ss << v.size() << v;
}
ss << emit_params(path.m_params);
);