diff options
author | John Hodge <tpg@mutabah.net> | 2016-12-16 19:09:33 +0800 |
---|---|---|
committer | John Hodge <tpg@mutabah.net> | 2016-12-16 19:09:33 +0800 |
commit | 07ad0a60696f1c453d5e21e8637077c6f77f483b (patch) | |
tree | 92ad8b2dd5dc2e49adc629fb0c34a401a1841f2a | |
parent | 36de5ba638817d89670e806fd1068bc3fdebecb1 (diff) | |
download | mrust-07ad0a60696f1c453d5e21e8637077c6f77f483b.tar.gz |
HIR From AST - Get link name
-rw-r--r-- | src/hir/from_ast.cpp | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/src/hir/from_ast.cpp b/src/hir/from_ast.cpp index a80ac887..c4e250a0 100644 --- a/src/hir/from_ast.cpp +++ b/src/hir/from_ast.cpp @@ -1060,14 +1060,31 @@ namespace { ::HIR::Linkage linkage; + // Convert #[link_name/no_mangle] attributes into the name if( const auto* a = attrs.get("link_name") ) { if( !a->has_string() ) ERROR(sp, E0000, "#[link_name] requires a string"); linkage.name = a->string(); } - // TODO: Convert #[link/link_name/no_mangle] attributes into linkage - // - Also, if there's no code, it's an external linkage? + else if( const auto* a = attrs.get("no_mangle") ) + { + (void)a; + linkage.name = p.get_name(); + } + else if( const auto* a = attrs.get("lang") ) + { + if( a->string() == "panic_fmt") + { + linkage.name = "rust_begin_unwind"; + } + } + else + { + // Leave linkage.name as empty + } + + // If there's no code, demangle the name (TODO: By ABI) and set linkage. if( linkage.name == "" && ! f.code().is_valid() ) { linkage.name = p.get_name(); |