aboutsummaryrefslogtreecommitdiff
path: root/src/ir.cpp
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2020-04-11 19:34:29 +0100
committergingerBill <bill@gingerbill.org>2020-04-11 19:34:29 +0100
commit7ba339e6bda99174b5f311d8897ea4f85ce853b7 (patch)
treeb68cd118bd52420d505aae50e0c21732f3de4272 /src/ir.cpp
parentbaf5b9edc31eda5fe79dd1fee4b9a4378b10bd8b (diff)
Fix link_name for variables
Diffstat (limited to 'src/ir.cpp')
-rw-r--r--src/ir.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/ir.cpp b/src/ir.cpp
index b14943d23..d0c101dbb 100644
--- a/src/ir.cpp
+++ b/src/ir.cpp
@@ -1756,6 +1756,10 @@ irValue *ir_add_local_for_identifier(irProcedure *proc, Ast *ident, bool zero_in
ir_emit_comment(proc, name);
if (e->kind == Entity_Variable &&
e->Variable.is_foreign) {
+ if (e->Variable.link_name.len != 0) {
+ name = e->Variable.link_name;
+ }
+
HashKey key = hash_string(name);
irValue **prev_value = map_get(&proc->module->members, key);
if (prev_value == nullptr) {
@@ -11943,6 +11947,9 @@ void ir_gen_tree(irGen *s) {
bool no_name_mangle = e->Variable.link_name.len > 0 || is_foreign || is_export;
String name = e->token.string;
+ if (e->Variable.link_name.len > 0) {
+ name = e->Variable.link_name;
+ }
if (!no_name_mangle) {
name = ir_mangle_name(s, e);
}