summaryrefslogtreecommitdiff
path: root/src/hir/from_ast.cpp
diff options
context:
space:
mode:
authorJohn Hodge <tpg@mutabah.net>2016-12-15 23:27:07 +0800
committerJohn Hodge <tpg@mutabah.net>2016-12-15 23:27:07 +0800
commit36de5ba638817d89670e806fd1068bc3fdebecb1 (patch)
tree1d9fd3d97420608b25fc21e1f0e4c4c58efce5f4 /src/hir/from_ast.cpp
parent2e361f85d70fbc07321c50c292b00ffacd095e1e (diff)
downloadmrust-36de5ba638817d89670e806fd1068bc3fdebecb1.tar.gz
Codegen - #[link_name] support
Diffstat (limited to 'src/hir/from_ast.cpp')
-rw-r--r--src/hir/from_ast.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/hir/from_ast.cpp b/src/hir/from_ast.cpp
index 729b0f45..a80ac887 100644
--- a/src/hir/from_ast.cpp
+++ b/src/hir/from_ast.cpp
@@ -1060,6 +1060,19 @@ namespace {
::HIR::Linkage linkage;
+ 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?
+ if( linkage.name == "" && ! f.code().is_valid() )
+ {
+ linkage.name = p.get_name();
+ }
+
return ::HIR::Function {
mv$(linkage),
receiver,