summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Hodge <tpg@mutabah.net>2016-12-04 19:44:25 +0800
committerJohn Hodge <tpg@mutabah.net>2016-12-04 19:44:25 +0800
commitf2b6b58c75e31398438e10ea6cd6d7a00268f8a7 (patch)
tree72c254b9fbf0e317a57df055c7328013a4a92a00
parentb9c9dce47c09a62f7955dc8b1e51533b705d1cd0 (diff)
downloadmrust-f2b6b58c75e31398438e10ea6cd6d7a00268f8a7.tar.gz
Trans Mangle - Escape # elsewhere in names
-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);
);