diff options
| author | Luqman Aden <laden@csclub.uwaterloo.ca> | 2013-08-31 13:23:31 -0400 |
|---|---|---|
| committer | Luqman Aden <laden@csclub.uwaterloo.ca> | 2013-08-31 13:23:31 -0400 |
| commit | ba5f101fa9fd426d673868ebb903a709528a66d1 (patch) | |
| tree | 9173021cd14ea08ba449da8a60d6a43e41c70c96 | |
| parent | bb35e23f1ca63eba4a3ea25ecdf68a393871ed18 (diff) | |
librustc: Add export_name attribute to specify symbol name.
| -rw-r--r-- | src/librustc/middle/trans/base.rs | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/src/librustc/middle/trans/base.rs b/src/librustc/middle/trans/base.rs index 1dc30d2221d..a5cbb1cfe1d 100644 --- a/src/librustc/middle/trans/base.rs +++ b/src/librustc/middle/trans/base.rs @@ -2453,10 +2453,16 @@ pub fn item_path(ccx: &CrateContext, id: &ast::NodeId) -> path { } fn exported_name(ccx: @mut CrateContext, path: path, ty: ty::t, attrs: &[ast::Attribute]) -> ~str { - if attr::contains_name(attrs, "no_mangle") { - path_elt_to_str(*path.last(), token::get_ident_interner()) - } else { - mangle_exported_name(ccx, path, ty) + match attr::first_attr_value_str_by_name(attrs, "export_name") { + // Use provided name + Some(name) => name.to_owned(), + + // Don't mangle + _ if attr::contains_name(attrs, "no_mangle") + => path_elt_to_str(*path.last(), token::get_ident_interner()), + + // Usual name mangling + _ => mangle_exported_name(ccx, path, ty) } } |
