From e530869aeb4ba08870c155342a972c10c2f2038b Mon Sep 17 00:00:00 2001 From: Christoffer Lerno Date: Wed, 30 Jun 2021 22:36:57 +0200 Subject: [PATCH] Change "cname" to "extname" --- src/compiler/compiler_internal.h | 2 +- src/compiler/enums.h | 2 +- src/compiler/llvm_codegen_function.c | 6 +++--- src/compiler/sema_decls.c | 22 +++++++++++----------- src/compiler/symtab.c | 2 +- 5 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/compiler/compiler_internal.h b/src/compiler/compiler_internal.h index 35d13082c..cc356daae 100644 --- a/src/compiler/compiler_internal.h +++ b/src/compiler/compiler_internal.h @@ -487,7 +487,7 @@ typedef struct Decl_ bool is_substruct : 1; bool has_variable_array : 1; void *backend_ref; - const char *cname; + const char *extname; AlignSize alignment; const char *section; ArrayIndex offset : 32; diff --git a/src/compiler/enums.h b/src/compiler/enums.h index 5e848e2e7..4c578dc97 100644 --- a/src/compiler/enums.h +++ b/src/compiler/enums.h @@ -594,7 +594,7 @@ typedef enum ATTRIBUTE_OPAQUE, ATTRIBUTE_NORETURN, ATTRIBUTE_SECTION, - ATTRIBUTE_CNAME, + ATTRIBUTE_EXTNAME, ATTRIBUTE_WEAK, ATTRIBUTE_ALIGN, ATTRIBUTE_PACKED, diff --git a/src/compiler/llvm_codegen_function.c b/src/compiler/llvm_codegen_function.c index 1c9a5c19f..09f2e191a 100644 --- a/src/compiler/llvm_codegen_function.c +++ b/src/compiler/llvm_codegen_function.c @@ -522,7 +522,7 @@ void llvm_emit_function_decl(GenContext *c, Decl *decl) { assert(decl->decl_kind == DECL_FUNC); // Resolve function backend type for function. - LLVMValueRef function = LLVMAddFunction(c->module, decl->cname ?: decl->external_name, llvm_get_type(c, decl->type)); + LLVMValueRef function = LLVMAddFunction(c->module, decl->extname ?: decl->external_name, llvm_get_type(c, decl->type)); decl->backend_ref = function; FunctionSignature *signature = &decl->func_decl.function_signature; FunctionSignature *type_signature = decl->type->func.signature; @@ -628,12 +628,12 @@ void llvm_emit_extern_decl(GenContext *context, Decl *decl) case DECL_POISONED: UNREACHABLE; case DECL_FUNC: - decl->backend_ref = LLVMAddFunction(context->module, decl->cname ?: decl->external_name, + decl->backend_ref = LLVMAddFunction(context->module, decl->extname ?: decl->external_name, llvm_get_type(context, decl->type)); LLVMSetVisibility(decl->backend_ref, LLVMDefaultVisibility); break; case DECL_VAR: - decl->backend_ref = LLVMAddGlobal(context->module, llvm_get_type(context, decl->type), decl->cname ?: decl->external_name); + decl->backend_ref = LLVMAddGlobal(context->module, llvm_get_type(context, decl->type), decl->extname ?: decl->external_name); LLVMSetVisibility(decl->backend_ref, LLVMDefaultVisibility); break; case DECL_STRUCT: diff --git a/src/compiler/sema_decls.c b/src/compiler/sema_decls.c index cbf6a2705..56355dc1c 100644 --- a/src/compiler/sema_decls.c +++ b/src/compiler/sema_decls.c @@ -289,9 +289,9 @@ static bool sema_analyse_struct_union(Context *context, Decl *decl) #define SET_ATTR(_X) had = decl->func_decl._X; decl->func_decl._X = true; break switch (attribute) { - case ATTRIBUTE_CNAME: - had = decl->cname != NULL; - decl->cname = attr->expr->const_expr.string.chars; + case ATTRIBUTE_EXTNAME: + had = decl->extname != NULL; + decl->extname = attr->expr->const_expr.string.chars; break; case ATTRIBUTE_SECTION: had = decl->section != NULL; @@ -685,7 +685,7 @@ static AttributeType sema_analyse_attribute(Context *context, Attr *attr, Attrib } static AttributeDomain attribute_domain[NUMBER_OF_ATTRIBUTES] = { [ATTRIBUTE_WEAK] = ATTR_FUNC | ATTR_CONST | ATTR_VAR, - [ATTRIBUTE_CNAME] = ~0, + [ATTRIBUTE_EXTNAME] = ~0, [ATTRIBUTE_SECTION] = ATTR_FUNC | ATTR_CONST | ATTR_VAR, [ATTRIBUTE_PACKED] = ATTR_STRUCT | ATTR_UNION | ATTR_ERROR, [ATTRIBUTE_NORETURN] = ATTR_FUNC, @@ -741,7 +741,7 @@ static AttributeType sema_analyse_attribute(Context *context, Attr *attr, Attrib } return type; case ATTRIBUTE_SECTION: - case ATTRIBUTE_CNAME: + case ATTRIBUTE_EXTNAME: if (context->module->is_generic) { SEMA_TOKID_ERROR(attr->name, "'cname' attributes are not allowed in generic modules."); @@ -804,9 +804,9 @@ static inline bool sema_analyse_func(Context *context, Decl *decl) #define SET_ATTR(_X) had = decl->func_decl._X; decl->func_decl._X = true; break switch (attribute) { - case ATTRIBUTE_CNAME: - had = decl->cname != NULL; - decl->cname = attr->expr->const_expr.string.chars; + case ATTRIBUTE_EXTNAME: + had = decl->extname != NULL; + decl->extname = attr->expr->const_expr.string.chars; break; case ATTRIBUTE_SECTION: had = decl->section != NULL; @@ -992,9 +992,9 @@ static inline bool sema_analyse_global(Context *context, Decl *decl) #define SET_ATTR(_X) had = decl->func_decl._X; decl->func_decl._X = true; break switch (attribute) { - case ATTRIBUTE_CNAME: - had = decl->cname != NULL; - decl->cname = attr->expr->const_expr.string.chars; + case ATTRIBUTE_EXTNAME: + had = decl->extname != NULL; + decl->extname = attr->expr->const_expr.string.chars; break; case ATTRIBUTE_SECTION: had = decl->section != NULL; diff --git a/src/compiler/symtab.c b/src/compiler/symtab.c index 49c168ac4..6605e9c7d 100644 --- a/src/compiler/symtab.c +++ b/src/compiler/symtab.c @@ -136,7 +136,7 @@ void symtab_init(uint32_t capacity) attribute_list[ATTRIBUTE_ALIGN] = kw_align; attribute_list[ATTRIBUTE_PACKED] = KW_DEF("packed"); attribute_list[ATTRIBUTE_SECTION] = KW_DEF("section"); - attribute_list[ATTRIBUTE_CNAME] = KW_DEF("cname"); + attribute_list[ATTRIBUTE_EXTNAME] = KW_DEF("extname"); attribute_list[ATTRIBUTE_WEAK] = KW_DEF("weak"); attribute_list[ATTRIBUTE_OPAQUE] = KW_DEF("opaque"); }