From 07ad0a60696f1c453d5e21e8637077c6f77f483b Mon Sep 17 00:00:00 2001 From: John Hodge Date: Fri, 16 Dec 2016 19:09:33 +0800 Subject: HIR From AST - Get link name --- src/hir/from_ast.cpp | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to 'src/hir/from_ast.cpp') 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(); -- cgit v1.2.3