-4a0bb435bbb1d1516b486d1998e8dc184576db61
+9a89f32811e6b3a29e22dda46e9c23811f562876
The first line of this file holds the git revision number of the last
merge done from the gofrontend repository.
return name.substr(1, name.rfind('.') - 1);
}
+ // Given a name which may or may not have been hidden, return the
+ // name to use within a mangled symbol name.
+ static std::string
+ mangle_possibly_hidden_name(const std::string& name)
+ {
+ // FIXME: This adds in pkgpath twice for hidden symbols, which is
+ // less than ideal.
+ std::string n;
+ if (!Gogo::is_hidden_name(name))
+ n = name;
+ else
+ {
+ n = ".";
+ std::string pkgpath = Gogo::hidden_name_pkgpath(name);
+ n.append(Gogo::pkgpath_for_symbol(pkgpath));
+ n.append(1, '.');
+ n.append(Gogo::unpack_hidden_name(name));
+ }
+ return n;
+ }
+
// Given a name which may or may not have been hidden, return the
// name to use in an error message.
static std::string
}
}
- // FIXME: This adds in pkgpath twice for hidden symbols, which is
- // pointless.
- const std::string& name(no->name());
- if (!Gogo::is_hidden_name(name))
- ret.append(name);
- else
- {
- ret.append(1, '.');
- ret.append(Gogo::pkgpath_for_symbol(Gogo::hidden_name_pkgpath(name)));
- ret.append(1, '.');
- ret.append(Gogo::unpack_hidden_name(name));
- }
+ std::string mname(Gogo::mangle_possibly_hidden_name(no->name()));
+ ret.append(mname);
return ret;
}
if (p->is_anonymous())
ret->append("0_");
else
- {
- std::string n = Gogo::unpack_hidden_name(p->field_name());
+ {
+
+ std::string n(Gogo::mangle_possibly_hidden_name(p->field_name()));
char buf[20];
snprintf(buf, sizeof buf, "%u_",
static_cast<unsigned int>(n.length()));
{
if (!p->name().empty())
{
- std::string n;
- if (!Gogo::is_hidden_name(p->name()))
- n = p->name();
- else
- {
- n = ".";
- std::string pkgpath = Gogo::hidden_name_pkgpath(p->name());
- n.append(Gogo::pkgpath_for_symbol(pkgpath));
- n.append(1, '.');
- n.append(Gogo::unpack_hidden_name(p->name()));
- }
+ std::string n(Gogo::mangle_possibly_hidden_name(p->name()));
char buf[20];
snprintf(buf, sizeof buf, "%u_",
static_cast<unsigned int>(n.length()));