diff --git a/releasenotes.md b/releasenotes.md index fe6bfc20e..ac9f1ba14 100644 --- a/releasenotes.md +++ b/releasenotes.md @@ -146,6 +146,7 @@ - Added posix socket functions. ### Fixes +- @local declarations in generic modules available by accident. - Fixes missing checks to body arguments. - Do not create debug declaration for value-only parameter. - Bug in alignment for atomics. diff --git a/src/compiler/abi/c_abi_aarch64.c b/src/compiler/abi/c_abi_aarch64.c index d890c7674..21ef4339e 100644 --- a/src/compiler/abi/c_abi_aarch64.c +++ b/src/compiler/abi/c_abi_aarch64.c @@ -182,7 +182,7 @@ ABIArgInfo *aarch64_classify_return_type(Type *type, bool variadic) Type *base = NULL; unsigned members = 0; if (type_is_homogenous_aggregate(type, &base, &members) && - !(platform_target.arch == ARCH_TYPE_AARCH64_32 && variadic)) + !(platform_target.arch == ARCH_TYPE_AARCH64_32 && variadic)) { return abi_arg_new_direct(); } diff --git a/src/compiler/abi/c_abi_riscv.c b/src/compiler/abi/c_abi_riscv.c index acf2956ff..c1bd3f276 100644 --- a/src/compiler/abi/c_abi_riscv.c +++ b/src/compiler/abi/c_abi_riscv.c @@ -63,11 +63,11 @@ static bool riscv_detect_fpcc_struct_internal(Type *type, unsigned current_offse for (ByteSize i = 0; i < array_len; i++) { if (!riscv_detect_fpcc_struct_internal(element_type, - current_offset, - field1_ref, - field1_offset, - field2_ref, - field2_offset)) return false; + current_offset, + field1_ref, + field1_offset, + field2_ref, + field2_offset)) return false; current_offset += (unsigned)element_size; } return true; @@ -82,11 +82,11 @@ static bool riscv_detect_fpcc_struct_internal(Type *type, unsigned current_offse { Decl *member = members[i]; if (!riscv_detect_fpcc_struct_internal(member->type, - (unsigned)(current_offset + member->offset), - field1_ref, - field1_offset, - field2_ref, - field2_offset)) return false; + (unsigned)(current_offset + member->offset), + field1_ref, + field1_offset, + field2_ref, + field2_offset)) return false; } return abi_type_is_valid(*field1_ref); @@ -156,12 +156,12 @@ static ABIArgInfo *riscv_classify_argument_type(Type *type, bool is_fixed, unsig unsigned needed_gprs; unsigned needed_fprs; bool is_candidate = riscv_detect_fpcc_struct(type, - &field1, - &offset1, - &field2, - &offset2, - &needed_gprs, - &needed_fprs); + &field1, + &offset1, + &field2, + &offset2, + &needed_gprs, + &needed_fprs); if (is_candidate && needed_gprs <= *gprs && needed_fprs <= *fprs) { *gprs -= needed_gprs; @@ -282,7 +282,7 @@ void c_abi_func_create_riscv(FunctionPrototype *prototype) if (prototype->ret_by_ref) { prototype->ret_by_ref_abi_info = riscv_classify_argument_type(type_get_ptr(type_lowering(prototype->ret_by_ref_type)), - true, &arg_gprs_left, &arg_fprs_left); + true, &arg_gprs_left, &arg_fprs_left); } prototype->abi_args = riscv_create_params(prototype->param_types, true, &arg_gprs_left, &arg_fprs_left); diff --git a/src/compiler/abi/c_abi_win64.c b/src/compiler/abi/c_abi_win64.c index 8e7422b70..b196d7253 100644 --- a/src/compiler/abi/c_abi_win64.c +++ b/src/compiler/abi/c_abi_win64.c @@ -23,7 +23,7 @@ ABIArgInfo *win64_classify(Regs *regs, Type *type, bool is_return, bool is_vecto { // Enough registers AND return / builtin / vector if (regs->float_regs >= elements && - (is_return || type_is_builtin(type->type_kind) || type->type_kind == TYPE_VECTOR)) + (is_return || type_is_builtin(type->type_kind) || type->type_kind == TYPE_VECTOR)) { regs->float_regs -= elements; return abi_arg_new_direct(); @@ -155,9 +155,9 @@ void c_abi_func_create_win64(FunctionPrototype *prototype) if (prototype->ret_by_ref) { prototype->ret_by_ref_abi_info = win64_classify(®s, - type_get_ptr(type_lowering(prototype->ret_by_ref_type)), - false, - is_vector_call); + type_get_ptr(type_lowering(prototype->ret_by_ref_type)), + false, + is_vector_call); } // Set up parameter registers. diff --git a/src/compiler/abi/c_abi_x64.c b/src/compiler/abi/c_abi_x64.c index 6813f425c..964bb7f83 100644 --- a/src/compiler/abi/c_abi_x64.c +++ b/src/compiler/abi/c_abi_x64.c @@ -311,7 +311,7 @@ void x64_classify_array(Type *type, ByteSize offset_base, X64Class *current, X64 } void x64_classify_vector(Type *type, ByteSize offset_base, X64Class *current, X64Class *lo_class, X64Class *hi_class, - NamedArgument named_arg) + NamedArgument named_arg) { unsigned size = type_size(type); // Pass as int @@ -582,8 +582,8 @@ AbiType x64_get_int_type_at_offset(Type *type, unsigned offset, Type *source_typ case TYPE_I32: if (offset) break; if (x64_bits_contain_no_user_data(source_type, - source_offset + type_size(type), - source_offset + 8)) + source_offset + type_size(type), + source_offset + 8)) { return abi_type_get(type); } @@ -919,8 +919,8 @@ void c_abi_func_create_x64(FunctionPrototype *prototype) if (prototype->ret_by_ref) { prototype->ret_by_ref_abi_info = x64_classify_parameter(type_get_ptr(type_lowering(prototype->ret_by_ref_type)), - &available_registers, - NAMED); + &available_registers, + NAMED); } Type **params = prototype->param_types; diff --git a/src/compiler/abi/c_abi_x86.c b/src/compiler/abi/c_abi_x86.c index 54fd844bf..2717e2512 100644 --- a/src/compiler/abi/c_abi_x86.c +++ b/src/compiler/abi/c_abi_x86.c @@ -412,7 +412,7 @@ static inline ABIArgInfo *x86_classify_aggregate(CallABI call, Regs *regs, Type // Don't do this for the MCU if there are still free integer registers // (see X86_64 ABI for full explanation). if (size <= 16 && (!platform_target.x86.is_mcu_api || !regs->int_regs) && - x86_can_expand_indirect_aggregate_arg(type)) + x86_can_expand_indirect_aggregate_arg(type)) { return abi_arg_new_expand(); } @@ -532,12 +532,12 @@ void c_abi_func_create_x86(FunctionPrototype *prototype) /* * // The chain argument effectively gives us another free register. if (FI.isChainCall()) - ++State.FreeRegs; + ++State.FreeRegs; // For vectorcall, do a first pass over the arguments, assigning FP and vector // arguments to XMM registers as available. if (State.CC == llvm::CallingConv::X86_VectorCall) - runVectorCallFirstPass(FI, State); + runVectorCallFirstPass(FI, State); */ prototype->abi_args = x86_create_params(prototype->call_abi, prototype->param_types, ®s); diff --git a/src/compiler/asm/aarch64.h b/src/compiler/asm/aarch64.h index 021011ab7..2e4670656 100644 --- a/src/compiler/asm/aarch64.h +++ b/src/compiler/asm/aarch64.h @@ -202,107 +202,107 @@ static const char *Aarch64ClobberNames[] = { }; static const char *aarch64_quad_regs[] = { "$x0", "$x1", "$x2", "$x3", "$x4", - "$x5", "$x6", "$x7", "$x8", "$x9", - "$x10", "$x11", "$x12", "$x13", "$x14", - "$x15", "$x16", "$x17", "$x18", "$x19", - "$x20", "$x21", "$x22", "$x23", "$x24", - "$x25", "$x26", "$x27", "$x28", "$x29", - "$x30", "$xzr" }; + "$x5", "$x6", "$x7", "$x8", "$x9", + "$x10", "$x11", "$x12", "$x13", "$x14", + "$x15", "$x16", "$x17", "$x18", "$x19", + "$x20", "$x21", "$x22", "$x23", "$x24", + "$x25", "$x26", "$x27", "$x28", "$x29", + "$x30", "$xzr" }; static const char *aarch64_long_regs[] = { "$w0", "$w1", "$w2", "$w3", "$w4", - "$w5", "$w6", "$w7", "$w8", "$w9", - "$w10", "$w11", "$w12", "$w13", "$w14", - "$w15", "$w16", "$w17", "$w18", "$w19", - "$w20", "$w21", "$w22", "$w23", "$w24", - "$w25", "$w26", "$w27", "$w28", "$w29", - "$w30", "$wzr" }; + "$w5", "$w6", "$w7", "$w8", "$w9", + "$w10", "$w11", "$w12", "$w13", "$w14", + "$w15", "$w16", "$w17", "$w18", "$w19", + "$w20", "$w21", "$w22", "$w23", "$w24", + "$w25", "$w26", "$w27", "$w28", "$w29", + "$w30", "$wzr" }; static const char *aarch64_f128_regs[] = { "$q0", "$q1", "$q2", "$q3", "$q4", - "$q5", "$q6", "$q7", "$q8", "$q9", - "$q10", "$q11", "$q12", "$q13", "$q14", - "$q15", "$q16", "$q17", "$q18", "$q19", - "$q20", "$q21", "$q22", "$q23", "$q24", - "$q25", "$q26", "$q27", "$q28", "$q29", - "$q30", "$q31" }; + "$q5", "$q6", "$q7", "$q8", "$q9", + "$q10", "$q11", "$q12", "$q13", "$q14", + "$q15", "$q16", "$q17", "$q18", "$q19", + "$q20", "$q21", "$q22", "$q23", "$q24", + "$q25", "$q26", "$q27", "$q28", "$q29", + "$q30", "$q31" }; static const char *aarch64_double_regs[] = { "$d0", "$d1", "$d2", "$d3", "$d4", - "$d5", "$d6", "$d7", "$d8", "$d9", - "$d10", "$d11", "$d12", "$d13", "$d14", - "$d15", "$d16", "$d17", "$d18", "$d19", - "$d20", "$d21", "$d22", "$d23", "$d24", - "$d25", "$d26", "$d27", "$d28", "$d29", - "$d30", "$d31" }; + "$d5", "$d6", "$d7", "$d8", "$d9", + "$d10", "$d11", "$d12", "$d13", "$d14", + "$d15", "$d16", "$d17", "$d18", "$d19", + "$d20", "$d21", "$d22", "$d23", "$d24", + "$d25", "$d26", "$d27", "$d28", "$d29", + "$d30", "$d31" }; static const char *aarch64_float_regs[] = { "$s0", "$s1", "$s2", "$s3", "$s4", - "$s5", "$s6", "$s7", "$s8", "$s9", - "$s10", "$s11", "$s12", "$s13", "$s14", - "$s15", "$s16", "$s17", "$s18", "$s19", - "$s20", "$s21", "$s22", "$s23", "$s24", - "$s25", "$s26", "$s27", "$s28", "$s29", - "$s30", "$s31" }; + "$s5", "$s6", "$s7", "$s8", "$s9", + "$s10", "$s11", "$s12", "$s13", "$s14", + "$s15", "$s16", "$s17", "$s18", "$s19", + "$s20", "$s21", "$s22", "$s23", "$s24", + "$s25", "$s26", "$s27", "$s28", "$s29", + "$s30", "$s31" }; static const char *aarch64_f16_regs[] = { "$h0", "$h1", "$h2", "$h3", "$h4", - "$h5", "$h6", "$h7", "$h8", "$h9", - "$h10", "$h11", "$h12", "$h13", "$h14", - "$h15", "$h16", "$h17", "$h18", "$h19", - "$h20", "$h21", "$h22", "$h23", "$h24", - "$h25", "$h26", "$h27", "$h28", "$h29", - "$h30", "$h31" }; + "$h5", "$h6", "$h7", "$h8", "$h9", + "$h10", "$h11", "$h12", "$h13", "$h14", + "$h15", "$h16", "$h17", "$h18", "$h19", + "$h20", "$h21", "$h22", "$h23", "$h24", + "$h25", "$h26", "$h27", "$h28", "$h29", + "$h30", "$h31" }; static const char *aarch64_f8_regs[] = { "$b0", "$b1", "$b2", "$b3", "$b4", - "$b5", "$b6", "$b7", "$b8", "$b9", - "$b10", "$b11", "$b12", "$b13", "$b14", - "$b15", "$b16", "$b17", "$b18", "$b19", - "$b20", "$b21", "$b22", "$b23", "$b24", - "$b25", "$b26", "$b27", "$b28", "$b29", - "$b30", "$b31" }; + "$b5", "$b6", "$b7", "$b8", "$b9", + "$b10", "$b11", "$b12", "$b13", "$b14", + "$b15", "$b16", "$b17", "$b18", "$b19", + "$b20", "$b21", "$b22", "$b23", "$b24", + "$b25", "$b26", "$b27", "$b28", "$b29", + "$b30", "$b31" }; static const char *aarch64_v8b_regs[] = { "$v0_8b", "$v1_8b", "$v2_8b", "$v3_8b", "$v4_8b", - "$v5_8b", "$v6_8b", "$v7_8b", "$v8_8b", "$v9_8b", - "$v10_8b", "$v11_8b", "$v12_8b", "$v13_8b", "$v14_8b", - "$v15_8b", "$v16_8b", "$v17_8b", "$v18_8b", "$v19_8b", - "$v20_8b", "$v21_8b", "$v22_8b", "$v23_8b", "$v24_8b", - "$v25_8b", "$v26_8b", "$v27_8b", "$v28_8b", "$v29_8b", - "$v30_8b", "$v31_8b" }; + "$v5_8b", "$v6_8b", "$v7_8b", "$v8_8b", "$v9_8b", + "$v10_8b", "$v11_8b", "$v12_8b", "$v13_8b", "$v14_8b", + "$v15_8b", "$v16_8b", "$v17_8b", "$v18_8b", "$v19_8b", + "$v20_8b", "$v21_8b", "$v22_8b", "$v23_8b", "$v24_8b", + "$v25_8b", "$v26_8b", "$v27_8b", "$v28_8b", "$v29_8b", + "$v30_8b", "$v31_8b" }; static const char *aarch64_v16b_regs[] = { "$v0_16b", "$v1_16b", "$v2_16b", "$v3_16b", "$v4_16b", - "$v5_16b", "$v6_16b", "$v7_16b", "$v8_16b", "$v9_16b", - "$v10_16b", "$v11_16b", "$v12_16b", "$v13_16b", "$v14_16b", - "$v15_16b", "$v16_16b", "$v17_16b", "$v18_16b", "$v19_16b", - "$v20_16b", "$v21_16b", "$v22_16b", "$v23_16b", "$v24_16b", - "$v25_16b", "$v26_16b", "$v27_16b", "$v28_16b", "$v29_16b", - "$v30_16b", "$v31_16b" }; + "$v5_16b", "$v6_16b", "$v7_16b", "$v8_16b", "$v9_16b", + "$v10_16b", "$v11_16b", "$v12_16b", "$v13_16b", "$v14_16b", + "$v15_16b", "$v16_16b", "$v17_16b", "$v18_16b", "$v19_16b", + "$v20_16b", "$v21_16b", "$v22_16b", "$v23_16b", "$v24_16b", + "$v25_16b", "$v26_16b", "$v27_16b", "$v28_16b", "$v29_16b", + "$v30_16b", "$v31_16b" }; static const char *aarch64_v4h_regs[] = { "$v0_4h", "$v1_4h", "$v2_4h", "$v3_4h", "$v4_4h", - "$v5_4h", "$v6_4h", "$v7_4h", "$v8_4h", "$v9_4h", - "$v10_4h", "$v11_4h", "$v12_4h", "$v13_4h", "$v14_4h", - "$v15_4h", "$v16_4h", "$v17_4h", "$v18_4h", "$v19_4h", - "$v20_4h", "$v21_4h", "$v22_4h", "$v23_4h", "$v24_4h", - "$v25_4h", "$v26_4h", "$v27_4h", "$v28_4h", "$v29_4h", - "$v30_4h", "$v31_4h" }; + "$v5_4h", "$v6_4h", "$v7_4h", "$v8_4h", "$v9_4h", + "$v10_4h", "$v11_4h", "$v12_4h", "$v13_4h", "$v14_4h", + "$v15_4h", "$v16_4h", "$v17_4h", "$v18_4h", "$v19_4h", + "$v20_4h", "$v21_4h", "$v22_4h", "$v23_4h", "$v24_4h", + "$v25_4h", "$v26_4h", "$v27_4h", "$v28_4h", "$v29_4h", + "$v30_4h", "$v31_4h" }; static const char *aarch64_v8h_regs[] = { "$v0_8h", "$v1_8h", "$v2_8h", "$v3_8h", "$v4_8h", - "$v5_8h", "$v6_8h", "$v7_8h", "$v8_8h", "$v9_8h", - "$v10_8h", "$v11_8h", "$v12_8h", "$v13_8h", "$v14_8h", - "$v15_8h", "$v16_8h", "$v17_8h", "$v18_8h", "$v19_8h", - "$v20_8h", "$v21_8h", "$v22_8h", "$v23_8h", "$v24_8h", - "$v25_8h", "$v26_8h", "$v27_8h", "$v28_8h", "$v29_8h", - "$v30_8h", "$v31_8h" }; + "$v5_8h", "$v6_8h", "$v7_8h", "$v8_8h", "$v9_8h", + "$v10_8h", "$v11_8h", "$v12_8h", "$v13_8h", "$v14_8h", + "$v15_8h", "$v16_8h", "$v17_8h", "$v18_8h", "$v19_8h", + "$v20_8h", "$v21_8h", "$v22_8h", "$v23_8h", "$v24_8h", + "$v25_8h", "$v26_8h", "$v27_8h", "$v28_8h", "$v29_8h", + "$v30_8h", "$v31_8h" }; static const char *aarch64_v2s_regs[] = { "$v0_2s", "$v1_2s", "$v2_2s", "$v3_2s", "$v4_2s", - "$v5_2s", "$v6_2s", "$v7_2s", "$v8_2s", "$v9_2s", - "$v10_2s", "$v11_2s", "$v12_2s", "$v13_2s", "$v14_2s", - "$v15_2s", "$v16_2s", "$v17_2s", "$v18_2s", "$v19_2s", - "$v20_2s", "$v21_2s", "$v22_2s", "$v23_2s", "$v24_2s", - "$v25_2s", "$v26_2s", "$v27_2s", "$v28_2s", "$v29_2s", - "$v30_2s", "$v31_2s" }; + "$v5_2s", "$v6_2s", "$v7_2s", "$v8_2s", "$v9_2s", + "$v10_2s", "$v11_2s", "$v12_2s", "$v13_2s", "$v14_2s", + "$v15_2s", "$v16_2s", "$v17_2s", "$v18_2s", "$v19_2s", + "$v20_2s", "$v21_2s", "$v22_2s", "$v23_2s", "$v24_2s", + "$v25_2s", "$v26_2s", "$v27_2s", "$v28_2s", "$v29_2s", + "$v30_2s", "$v31_2s" }; static const char *aarch64_v4s_regs[] = { "$v0_4s", "$v1_4s", "$v2_4s", "$v3_4s", "$v4_4s", - "$v5_4s", "$v6_4s", "$v7_4s", "$v8_4s", "$v9_4s", - "$v10_4s", "$v11_4s", "$v12_4s", "$v13_4s", "$v14_4s", - "$v15_4s", "$v16_4s", "$v17_4s", "$v18_4s", "$v19_4s", - "$v20_4s", "$v21_4s", "$v22_4s", "$v23_4s", "$v24_4s", - "$v25_4s", "$v26_4s", "$v27_4s", "$v28_4s", "$v29_4s", - "$v30_4s", "$v31_4s" }; + "$v5_4s", "$v6_4s", "$v7_4s", "$v8_4s", "$v9_4s", + "$v10_4s", "$v11_4s", "$v12_4s", "$v13_4s", "$v14_4s", + "$v15_4s", "$v16_4s", "$v17_4s", "$v18_4s", "$v19_4s", + "$v20_4s", "$v21_4s", "$v22_4s", "$v23_4s", "$v24_4s", + "$v25_4s", "$v26_4s", "$v27_4s", "$v28_4s", "$v29_4s", + "$v30_4s", "$v31_4s" }; static const char *aarch64_v1d_regs[] = { "$v0_1d", "$v1_1d", "$v2_1d", "$v3_1d", "$v4_1d", - "$v5_1d", "$v6_1d", "$v7_1d", "$v8_1d", "$v9_1d", - "$v10_1d", "$v11_1d", "$v12_1d", "$v13_1d", "$v14_1d", - "$v15_1d", "$v16_1d", "$v17_1d", "$v18_1d", "$v19_1d", - "$v20_1d", "$v21_1d", "$v22_1d", "$v23_1d", "$v24_1d", - "$v25_1d", "$v26_1d", "$v27_1d", "$v28_1d", "$v29_1d", - "$v30_1d", "$v31_1d" }; + "$v5_1d", "$v6_1d", "$v7_1d", "$v8_1d", "$v9_1d", + "$v10_1d", "$v11_1d", "$v12_1d", "$v13_1d", "$v14_1d", + "$v15_1d", "$v16_1d", "$v17_1d", "$v18_1d", "$v19_1d", + "$v20_1d", "$v21_1d", "$v22_1d", "$v23_1d", "$v24_1d", + "$v25_1d", "$v26_1d", "$v27_1d", "$v28_1d", "$v29_1d", + "$v30_1d", "$v31_1d" }; static const char *aarch64_v2d_regs[] = { "$v0_2d", "$v1_2d", "$v2_2d", "$v3_2d", "$v4_2d", - "$v5_2d", "$v6_2d", "$v7_2d", "$v8_2d", "$v9_2d", - "$v10_2d", "$v11_2d", "$v12_2d", "$v13_2d", "$v14_2d", - "$v15_2d", "$v16_2d", "$v17_2d", "$v18_2d", "$v19_2d", - "$v20_2d", "$v21_2d", "$v22_2d", "$v23_2d", "$v24_2d", - "$v25_2d", "$v26_2d", "$v27_2d", "$v28_2d", "$v29_2d", - "$v30_2d", "$v31_2d" }; \ No newline at end of file + "$v5_2d", "$v6_2d", "$v7_2d", "$v8_2d", "$v9_2d", + "$v10_2d", "$v11_2d", "$v12_2d", "$v13_2d", "$v14_2d", + "$v15_2d", "$v16_2d", "$v17_2d", "$v18_2d", "$v19_2d", + "$v20_2d", "$v21_2d", "$v22_2d", "$v23_2d", "$v24_2d", + "$v25_2d", "$v26_2d", "$v27_2d", "$v28_2d", "$v29_2d", + "$v30_2d", "$v31_2d" }; \ No newline at end of file diff --git a/src/compiler/asm/x86.h b/src/compiler/asm/x86.h index c1255d130..cca705367 100644 --- a/src/compiler/asm/x86.h +++ b/src/compiler/asm/x86.h @@ -139,26 +139,26 @@ static const char *X86ClobberNames[] = { }; static const char *x64_quad_regs[] = { "$rax", "$rbx", "$rcx", "$rdx", "$rsp", - "$rbp", "$rsi", "$rdi", "$r8", "$r9", - "$r10", "$r11", "$r12", "$r13", "$r14", "$r15" }; + "$rbp", "$rsi", "$rdi", "$r8", "$r9", + "$r10", "$r11", "$r12", "$r13", "$r14", "$r15" }; static const char *x86_long_regs[] = { "$eax", "$ebx", "$ecx", "$edx", "$esp", - "$ebp", "$esi", "$edi", "$r8d", "$r9d", - "$r10d", "$r11d", "$r12d", "$r13d", "$r14d", "$r15d" }; + "$ebp", "$esi", "$edi", "$r8d", "$r9d", + "$r10d", "$r11d", "$r12d", "$r13d", "$r14d", "$r15d" }; static const char *x86_word_regs[] = { "$ax", "$bx", "$cx", "$dx", "$sp", - "$bp", "$si", "$di", "$r8w", "$r9w", - "$r10w", "$r11w", "$r12w", "$r13w", "$r14w", "$r15w" }; + "$bp", "$si", "$di", "$r8w", "$r9w", + "$r10w", "$r11w", "$r12w", "$r13w", "$r14w", "$r15w" }; static const char *x86_low_byte_regs[] = { "$al", "$bl", "$cl", "$dl", - "$spl", "$bpl", "$sil", "$dil", "$r8b", "$r9b", - "$r10b", "$r11b", "$r12b", "$r13b", "$r14b", "$r15b" }; + "$spl", "$bpl", "$sil", "$dil", "$r8b", "$r9b", + "$r10b", "$r11b", "$r12b", "$r13b", "$r14b", "$r15b" }; static const char *x86_high_byte_regs[] = { "$ah", "$bh", "$ch", "$dh" }; static const char *x86_float_regs[] = { "$st0", "$st1", "$st2", "$st3", "$st4", "$st5", "$st6", "$st7" }; static const char *x86_xmm_regs[] = { "$xmm0", "$xmm1", "$xmm2", "$xmm3", "$xmm4", "$xmm5", "$xmm6", "$xmm7", - "$xmm8", "$xmm9", "$xmm10", "$xmm11", "$xmm12", "$xmm13", "$xmm14", "$xmm15" }; + "$xmm8", "$xmm9", "$xmm10", "$xmm11", "$xmm12", "$xmm13", "$xmm14", "$xmm15" }; static const char *x86_ymm_regs[] = { "$ymm0", "$ymm1", "$ymm2", "$ymm3", "$ymm4", "$ymm5", "$ymm6", "$ymm7", - "$ymm8", "$ymm9", "$ymm10", "$ymm11", "$ymm12", "$ymm13", "$ymm14", "$ymm15" }; + "$ymm8", "$ymm9", "$ymm10", "$ymm11", "$ymm12", "$ymm13", "$ymm14", "$ymm15" }; static const char *x86_zmm_regs[] = { "$zmm0", "$zmm1", "$zmm2", "$zmm3", "$zmm4", "$zmm5", "$zmm6", "$zmm7", - "$zmm8", "$zmm9", "$zmm10", "$zmm11", "$zmm12", "$zmm13", "$zmm14", "$zmm15" }; + "$zmm8", "$zmm9", "$zmm10", "$zmm11", "$zmm12", "$zmm13", "$zmm14", "$zmm15" }; diff --git a/src/compiler/bigint.c b/src/compiler/bigint.c index f538a6e14..86c58d08c 100644 --- a/src/compiler/bigint.c +++ b/src/compiler/bigint.c @@ -74,7 +74,7 @@ char *int_to_str(Int i, int radix) Int int_from_real(Real d, TypeKind type) { return (Int){ type_kind_is_unsigned(type) ? i128_from_float_unsigned(d) : i128_from_float_signed(d), - type }; + type }; } Int128 i128_from_int(uint64_t i) diff --git a/src/compiler/codegen_internal.h b/src/compiler/codegen_internal.h index 319c364b5..7153c0afc 100644 --- a/src/compiler/codegen_internal.h +++ b/src/compiler/codegen_internal.h @@ -112,7 +112,7 @@ static inline bool abi_type_is_promotable_integer_or_bool(AbiType type) static inline bool expr_is_vector_index(Expr *expr) { return expr->expr_kind == EXPR_SUBSCRIPT - && type_lowering(exprtype(expr->subscript_expr.expr))->type_kind == TYPE_VECTOR; + && type_lowering(exprtype(expr->subscript_expr.expr))->type_kind == TYPE_VECTOR; } const char *codegen_create_asm(Ast *ast); diff --git a/src/compiler/compiler.c b/src/compiler/compiler.c index 5b3a1091c..4afb1b679 100644 --- a/src/compiler/compiler.c +++ b/src/compiler/compiler.c @@ -49,7 +49,7 @@ void compiler_init(const char *std_lib_dir) global_context.module_list = NULL; global_context.generic_module_list = NULL; global_context.method_extensions = NULL; - global_context.section_list = NULL; + global_context.section_list = NULL; vmem_init(&ast_arena, 512); ast_calloc(); vmem_init(&expr_arena, 512); @@ -246,7 +246,7 @@ static void free_arenas(void) printf(" * TypeInfo size: %u bytes\n", (unsigned)sizeof(TypeInfo)); printf(" * Ast memory use: %llukb (%u elements)\n", (unsigned long long)ast_arena.allocated / 1024, - (unsigned)(ast_arena.allocated / sizeof(Ast))); + (unsigned)(ast_arena.allocated / sizeof(Ast))); printf(" * Decl memory use: %llukb (%u elements)\n", (unsigned long long)decl_arena.allocated / 1024, (unsigned)(decl_arena.allocated / sizeof(Decl))); @@ -479,7 +479,7 @@ void compiler_compile(void) { compiler_print_bench(); if (!obj_format_linking_supported(platform_target.object_format) || !linker(output_exe, obj_files, - output_file_count)) + output_file_count)) { printf("No linking is performed due to missing linker support.\n"); active_target.run_after_compile = false; @@ -877,21 +877,21 @@ void global_context_add_generic_decl(Decl *decl) SectionId global_context_register_section(const char *section) { - scratch_buffer_clear(); - scratch_buffer_append("SECTION#"); - scratch_buffer_append(section); - TokenType type = TOKEN_INVALID_TOKEN; - const char *result = scratch_buffer_interned(); - FOREACH_BEGIN_IDX(i, const char *candidate, global_context.section_list) - if (result == candidate) return i + 1; - FOREACH_END(); - unsigned len = vec_size(global_context.section_list); - if (len >= MAX_SECTIONS) - { - error_exit("Too many sections in source, max %d allowed.", MAX_SECTIONS); - } - vec_add(global_context.section_list, result); - return len + 1; + scratch_buffer_clear(); + scratch_buffer_append("SECTION#"); + scratch_buffer_append(section); + TokenType type = TOKEN_INVALID_TOKEN; + const char *result = scratch_buffer_interned(); + FOREACH_BEGIN_IDX(i, const char *candidate, global_context.section_list) + if (result == candidate) return i + 1; + FOREACH_END(); + unsigned len = vec_size(global_context.section_list); + if (len >= MAX_SECTIONS) + { + error_exit("Too many sections in source, max %d allowed.", MAX_SECTIONS); + } + vec_add(global_context.section_list, result); + return len + 1; } void global_context_clear_errors(void) @@ -957,6 +957,6 @@ const char *scratch_buffer_interned(void) { TokenType type = TOKEN_INVALID_TOKEN; return symtab_add(scratch_buffer.str, scratch_buffer.len, - fnv1a(scratch_buffer.str, scratch_buffer.len), &type); + fnv1a(scratch_buffer.str, scratch_buffer.len), &type); } diff --git a/src/compiler/compiler_internal.h b/src/compiler/compiler_internal.h index e9f750c2f..49a880f14 100644 --- a/src/compiler/compiler_internal.h +++ b/src/compiler/compiler_internal.h @@ -679,11 +679,11 @@ typedef struct Decl_ void *tb_symbol; }; AlignSize alignment; - union - { - SectionId section_id; - uint16_t va_index; - }; + union + { + SectionId section_id; + uint16_t va_index; + }; AlignSize offset : 32; AlignSize padding : 32; struct CompilationUnit_ *unit; @@ -1716,7 +1716,7 @@ typedef struct Decl *decl_stack[MAX_GLOBAL_DECL_STACK]; Decl **decl_stack_bottom; Decl **decl_stack_top; - const char **section_list; + const char **section_list; } GlobalContext; @@ -3335,15 +3335,15 @@ static inline bool decl_is_var_local(Decl *decl) if (decl->decl_kind != DECL_VAR) return false; VarDeclKind kind = decl->var.kind; return kind == VARDECL_PARAM_CT_TYPE - || kind == VARDECL_PARAM - || kind == VARDECL_PARAM_CT - || kind == VARDECL_LOCAL - || kind == VARDECL_LOCAL_CT_TYPE - || kind == VARDECL_LOCAL_CT - || kind == VARDECL_PARAM_REF - || kind == VARDECL_PARAM_EXPR - || kind == VARDECL_BITMEMBER - || kind == VARDECL_MEMBER; + || kind == VARDECL_PARAM + || kind == VARDECL_PARAM_CT + || kind == VARDECL_LOCAL + || kind == VARDECL_LOCAL_CT_TYPE + || kind == VARDECL_LOCAL_CT + || kind == VARDECL_PARAM_REF + || kind == VARDECL_PARAM_EXPR + || kind == VARDECL_BITMEMBER + || kind == VARDECL_MEMBER; } INLINE bool expr_is_const_string(Expr *expr) @@ -3393,5 +3393,5 @@ INLINE bool expr_is_const_member(Expr *expr) INLINE const char *section_from_id(SectionId id) { - return id ? global_context.section_list[id - 1] + SECTION_PREFIX_LEN : NULL; + return id ? global_context.section_list[id - 1] + SECTION_PREFIX_LEN : NULL; } diff --git a/src/compiler/context.c b/src/compiler/context.c index 878f498f2..96a993585 100644 --- a/src/compiler/context.c +++ b/src/compiler/context.c @@ -8,16 +8,16 @@ CompilationUnit *unit_create(File *file) { CompilationUnit *unit = CALLOCS(CompilationUnit); - unit->file = file; + unit->file = file; unit->is_interface_file = str_has_suffix(file->name, ".c3i"); htable_init(&unit->local_symbols, 1024); - return unit; + return unit; } static inline bool create_module_or_check_name(CompilationUnit *unit, Path *module_name, const char **parameters) { - Module *module = unit->module; + Module *module = unit->module; if (!module) { module = unit->module = compiler_find_or_create_module(module_name, parameters); @@ -27,9 +27,9 @@ static inline bool create_module_or_check_name(CompilationUnit *unit, Path *modu if (unit->module->name->module != module_name->module) { SEMA_ERROR(module_name, - "Module name here '%s' did not match actual module '%s'.", - module_name->module, - module->name->module); + "Module name here '%s' did not match actual module '%s'.", + module_name->module, + module->name->module); return false; } } @@ -71,40 +71,40 @@ bool context_set_module_from_filename(ParseContext *context) { File *file = context->unit->file; if (!filename_to_module_in_buffer(file->full_path)) - { + { sema_error(context, "The filename '%s' could not be converted to a valid module name, try using an explicit module name.", file->full_path); - return false; - } + return false; + } - TokenType type = TOKEN_IDENT; + TokenType type = TOKEN_IDENT; const char *module_name = symtab_add(scratch_buffer.str, - scratch_buffer.len, - fnv1a(scratch_buffer.str, (uint32_t) scratch_buffer.len), - &type); + scratch_buffer.len, + fnv1a(scratch_buffer.str, (uint32_t) scratch_buffer.len), + &type); - if (type != TOKEN_IDENT) - { - sema_error(context, "Generating a filename from the file '%s' resulted in a name that is a reserved keyword, " - "try using an explicit module name.", file->full_path); - return false; - } - Path *path = CALLOCS(Path); - path->span = INVALID_SPAN; - path->module = module_name; - path->len = scratch_buffer.len; - return create_module_or_check_name(context->unit, path, NULL); + if (type != TOKEN_IDENT) + { + sema_error(context, "Generating a filename from the file '%s' resulted in a name that is a reserved keyword, " + "try using an explicit module name.", file->full_path); + return false; + } + Path *path = CALLOCS(Path); + path->span = INVALID_SPAN; + path->module = module_name; + path->len = scratch_buffer.len; + return create_module_or_check_name(context->unit, path, NULL); } bool context_set_module(ParseContext *context, Path *path, const char **generic_parameters) { - // Note that we allow the illegal name for now, to be able to parse further. - if (!str_has_no_uppercase(path->module)) - { - SEMA_ERROR(path, "A module name may not have any uppercase characters."); - return false; - } + // Note that we allow the illegal name for now, to be able to parse further. + if (!str_has_no_uppercase(path->module)) + { + SEMA_ERROR(path, "A module name may not have any uppercase characters."); + return false; + } - return create_module_or_check_name(context->unit, path, generic_parameters); + return create_module_or_check_name(context->unit, path, generic_parameters); } @@ -264,7 +264,7 @@ ERR: bool unit_add_import(CompilationUnit *unit, Path *path, bool private_import) { - DEBUG_LOG("SEMA: Add import of '%s'.", path->module); + DEBUG_LOG("SEMA: Add import of '%s'.", path->module); if (!str_has_no_uppercase(path->module)) { @@ -278,8 +278,8 @@ bool unit_add_import(CompilationUnit *unit, Path *path, bool private_import) import->import.path = path; import->import.import_private_as_public = private_import; - vec_add(unit->imports, import); + vec_add(unit->imports, import); DEBUG_LOG("Added import %s", path->module); - return true; + return true; } diff --git a/src/compiler/enums.h b/src/compiler/enums.h index 6c177320d..d5c2bcaba 100644 --- a/src/compiler/enums.h +++ b/src/compiler/enums.h @@ -155,7 +155,7 @@ typedef enum #define NON_TYPE_DECLS DECL_IMPORT: case DECL_MACRO: \ case DECL_DECLARRAY: case DECL_ATTRIBUTE: case DECL_LABEL: \ - case DECL_DEFINE: case DECL_CT_ASSERT: case DECL_INITIALIZE: \ + case DECL_DEFINE: case DECL_CT_ASSERT: case DECL_INITIALIZE: \ case DECL_FINALIZE: case DECL_CT_ECHO: case DECL_CT_INCLUDE: case DECL_GLOBALS #define NON_RUNTIME_EXPR EXPR_DESIGNATOR: case EXPR_POISONED: \ diff --git a/src/compiler/expr.c b/src/compiler/expr.c index 8508991bd..6efbd6b42 100644 --- a/src/compiler/expr.c +++ b/src/compiler/expr.c @@ -737,16 +737,16 @@ bool expr_is_pure(Expr *expr) return exprid_is_pure(expr->typeid_info_expr.parent); case EXPR_SLICE: return exprid_is_pure(expr->subscript_expr.expr) - && exprid_is_pure(expr->subscript_expr.range.start) - && exprid_is_pure(expr->subscript_expr.range.end); + && exprid_is_pure(expr->subscript_expr.range.start) + && exprid_is_pure(expr->subscript_expr.range.end); case EXPR_SUBSCRIPT: case EXPR_SUBSCRIPT_ADDR: return exprid_is_pure(expr->subscript_expr.expr) - && exprid_is_pure(expr->subscript_expr.range.start); + && exprid_is_pure(expr->subscript_expr.range.start); case EXPR_TERNARY: return exprid_is_pure(expr->ternary_expr.cond) - && exprid_is_pure(expr->ternary_expr.else_expr) - && exprid_is_pure(expr->ternary_expr.then_expr); + && exprid_is_pure(expr->ternary_expr.else_expr) + && exprid_is_pure(expr->ternary_expr.then_expr); case EXPR_ASM: return false; case EXPR_GROUP: diff --git a/src/compiler/lexer.c b/src/compiler/lexer.c index ab39263f4..a3638872b 100644 --- a/src/compiler/lexer.c +++ b/src/compiler/lexer.c @@ -737,7 +737,7 @@ static inline bool scan_char(Lexer *lexer) if (peek(lexer) == '\0') continue; backtrack(lexer); return add_error_token_at_current(lexer, "Unicode character literals may only contain one character, " - "please remove the additional ones or use all ASCII."); + "please remove the additional ones or use all ASCII."); } b.low = (uint64_t) utf8; width = utf8 > 0xffff ? 4 : 2; @@ -788,8 +788,8 @@ static inline bool scan_char(Lexer *lexer) { begin_new_token(lexer); return add_error_token_at(lexer, escape_begin, lexer->current - escape_begin, - "Expected %s character hex value after \\%c.", - escape == 'u' ? "a four" : "an eight", escape); + "Expected %s character hex value after \\%c.", + escape == 'u' ? "a four" : "an eight", escape); } // If we don't see the end here, then something is wrong. if (!match(lexer, '\'')) @@ -797,8 +797,8 @@ static inline bool scan_char(Lexer *lexer) // It may be the end of the line, if so use the default handling by invoking "continue" if (peek(lexer) == '\0') continue; return add_error_token_at_current(lexer, - "Character literals with '\\%c' can only contain one character, please remove this one.", - escape); + "Character literals with '\\%c' can only contain one character, please remove this one.", + escape); } // Assign the value and go to "DONE". b.low = (uint64_t) hex; @@ -951,8 +951,8 @@ static inline bool scan_string(Lexer *lexer) { if (c == '\0') backtrack(lexer); add_error_token_at_start(lexer, "The end of the file was reached " - "while parsing the string. " - "Did you forget (or accidentally add) a '\"' somewhere?"); + "while parsing the string. " + "Did you forget (or accidentally add) a '\"' somewhere?"); consume_to_end_quote(lexer); return false; } @@ -961,8 +961,8 @@ static inline bool scan_string(Lexer *lexer) backtrack(lexer); add_error_token_at_start(lexer, "The end of the line was reached " - "while parsing the string. " - "Did you forget (or accidentally add) a '\"' somewhere?"); + "while parsing the string. " + "Did you forget (or accidentally add) a '\"' somewhere?"); consume_to_end_quote(lexer); return false; } @@ -999,8 +999,8 @@ static inline bool scan_raw_string(Lexer *lexer) if (c == '\0') { return add_error_token_at_start(lexer, "Reached the end of the file looking for " - "the end of the raw string that starts " - "here. Did you forget a '`' somewhere?"); + "the end of the raw string that starts " + "here. Did you forget a '`' somewhere?"); } if (c == '`') next(lexer); } @@ -1140,7 +1140,7 @@ static inline bool scan_base64(Lexer *lexer) if ((len + end_len) % 4 != 0) { return add_error_token_at_start(lexer, "Base64 strings must either be padded to multiple of 4, or if unpadded " - "- only need 1 or 2 bytes of extra padding."); + "- only need 1 or 2 bytes of extra padding."); } uint64_t decoded_len = (3 * len - end_len) / 4; if (!return_token(lexer, TOKEN_BYTES, lexer->lexing_start)) return false; @@ -1350,8 +1350,8 @@ static bool lexer_scan_token_inner(Lexer *lexer) return match(lexer, '=') ? return_token(lexer, TOKEN_EQEQ, "==") : return_token(lexer, TOKEN_EQ, "="); case '^': return match(lexer, '=') ? return_token(lexer, TOKEN_BIT_XOR_ASSIGN, "^=") : return_token(lexer, - TOKEN_BIT_XOR, - "^"); + TOKEN_BIT_XOR, + "^"); case '?': if (match(lexer, '?')) return return_token(lexer, TOKEN_QUESTQUEST, "??"); return match(lexer, ':') ? return_token(lexer, TOKEN_ELVIS, "?:") : return_token(lexer, TOKEN_QUESTION, "?"); @@ -1371,21 +1371,21 @@ static bool lexer_scan_token_inner(Lexer *lexer) if (match(lexer, ')')) return return_token(lexer, TOKEN_RGENPAR, ">)"); if (match(lexer, ']')) return return_token(lexer, TOKEN_RVEC, ">]"); return match(lexer, '=') ? return_token(lexer, TOKEN_GREATER_EQ, ">=") : return_token(lexer, - TOKEN_GREATER, - ">"); + TOKEN_GREATER, + ">"); case '%': return match(lexer, '=') ? return_token(lexer, TOKEN_MOD_ASSIGN, "%=") : return_token(lexer, TOKEN_MOD, "%"); case '&': if (match(lexer, '&')) return return_token(lexer, TOKEN_AND, "&&"); return match(lexer, '=') ? return_token(lexer, TOKEN_BIT_AND_ASSIGN, "&=") : return_token(lexer, - TOKEN_AMP, - "&"); + TOKEN_AMP, + "&"); case '|': if (match(lexer, '}')) return return_token(lexer, TOKEN_RBRAPIPE, "|}"); if (match(lexer, '|')) return return_token(lexer, TOKEN_OR, "||"); return match(lexer, '=') ? return_token(lexer, TOKEN_BIT_OR_ASSIGN, "|=") : return_token(lexer, - TOKEN_BIT_OR, - "|"); + TOKEN_BIT_OR, + "|"); case '+': if (match(lexer, '+')) return return_token(lexer, TOKEN_PLUSPLUS, "++"); if (match(lexer, '=')) return return_token(lexer, TOKEN_PLUS_ASSIGN, "+="); diff --git a/src/compiler/libraries.c b/src/compiler/libraries.c index 3aa572bf4..11ee2e4e9 100644 --- a/src/compiler/libraries.c +++ b/src/compiler/libraries.c @@ -58,7 +58,7 @@ static inline void parse_provides(Library *library, JSONObject *object) static inline void parse_depends(Library *library, JSONObject *object) { JSONObject *depends = get_optional_string_array(library, object, "depends"); - if (!depends) return; + if (!depends) return; TODO } @@ -137,8 +137,8 @@ static void add_library_dependency(Library *library, Library **library_list, siz VECEACH(target_found->depends, i) { add_library_dependency(find_library(library_list, lib_count, target_found->depends[i]), - library_list, - lib_count); + library_list, + lib_count); } } diff --git a/src/compiler/linker.c b/src/compiler/linker.c index a3fba616d..d695237aa 100644 --- a/src/compiler/linker.c +++ b/src/compiler/linker.c @@ -481,7 +481,7 @@ static void linker_setup_freebsd(const char ***args_ref, LinkerType linker_type) } static bool linker_setup(const char ***args_ref, const char **files_to_link, unsigned file_count, - const char *output_file, LinkerType linker_type) + const char *output_file, LinkerType linker_type) { bool is_dylib = active_target.type == TARGET_TYPE_DYNAMIC_LIB; bool use_win = linker_type == LINKER_LINK_EXE; @@ -907,22 +907,22 @@ bool linker(const char *output_file, const char **files, unsigned file_count) /** * From Clang * .Cases("aarch64elf", "aarch64linux", {ELF64LEKind, EM_AARCH64}) - .Cases("aarch64elfb", "aarch64linuxb", {ELF64BEKind, EM_AARCH64}) - .Cases("armelf", "armelf_linux_eabi", {ELF32LEKind, EM_ARM}) - .Case("elf32_x86_64", {ELF32LEKind, EM_X86_64}) - .Cases("elf32btsmip", "elf32btsmipn32", {ELF32BEKind, EM_MIPS}) - .Cases("elf32ltsmip", "elf32ltsmipn32", {ELF32LEKind, EM_MIPS}) - .Case("elf32lriscv", {ELF32LEKind, EM_RISCV}) - .Cases("elf32ppc", "elf32ppclinux", {ELF32BEKind, EM_PPC}) - .Cases("elf32lppc", "elf32lppclinux", {ELF32LEKind, EM_PPC}) - .Case("elf64btsmip", {ELF64BEKind, EM_MIPS}) - .Case("elf64ltsmip", {ELF64LEKind, EM_MIPS}) - .Case("elf64lriscv", {ELF64LEKind, EM_RISCV}) - .Case("elf64ppc", {ELF64BEKind, EM_PPC64}) - .Case("elf64lppc", {ELF64LEKind, EM_PPC64}) - .Cases("elf_amd64", "elf_x86_64", {ELF64LEKind, EM_X86_64}) - .Case("elf_i386", {ELF32LEKind, EM_386}) - .Case("elf_iamcu", {ELF32LEKind, EM_IAMCU}) - .Case("elf64_sparc", {ELF64BEKind, EM_SPARCV9}) - .Case("msp430elf", {ELF32LEKind, EM_MSP430}) + .Cases("aarch64elfb", "aarch64linuxb", {ELF64BEKind, EM_AARCH64}) + .Cases("armelf", "armelf_linux_eabi", {ELF32LEKind, EM_ARM}) + .Case("elf32_x86_64", {ELF32LEKind, EM_X86_64}) + .Cases("elf32btsmip", "elf32btsmipn32", {ELF32BEKind, EM_MIPS}) + .Cases("elf32ltsmip", "elf32ltsmipn32", {ELF32LEKind, EM_MIPS}) + .Case("elf32lriscv", {ELF32LEKind, EM_RISCV}) + .Cases("elf32ppc", "elf32ppclinux", {ELF32BEKind, EM_PPC}) + .Cases("elf32lppc", "elf32lppclinux", {ELF32LEKind, EM_PPC}) + .Case("elf64btsmip", {ELF64BEKind, EM_MIPS}) + .Case("elf64ltsmip", {ELF64LEKind, EM_MIPS}) + .Case("elf64lriscv", {ELF64LEKind, EM_RISCV}) + .Case("elf64ppc", {ELF64BEKind, EM_PPC64}) + .Case("elf64lppc", {ELF64LEKind, EM_PPC64}) + .Cases("elf_amd64", "elf_x86_64", {ELF64LEKind, EM_X86_64}) + .Case("elf_i386", {ELF32LEKind, EM_386}) + .Case("elf_iamcu", {ELF32LEKind, EM_IAMCU}) + .Case("elf64_sparc", {ELF64BEKind, EM_SPARCV9}) + .Case("msp430elf", {ELF32LEKind, EM_MSP430}) */ diff --git a/src/compiler/llvm_codegen.c b/src/compiler/llvm_codegen.c index 4d9fe3b39..637f00531 100644 --- a/src/compiler/llvm_codegen.c +++ b/src/compiler/llvm_codegen.c @@ -11,8 +11,8 @@ typedef struct LLVMOpaquePassBuilderOptions *LLVMPassBuilderOptionsRef; LLVMErrorRef LLVMRunPasses(LLVMModuleRef M, const char *Passes, - LLVMTargetMachineRef TM, - LLVMPassBuilderOptionsRef Options); + LLVMTargetMachineRef TM, + LLVMPassBuilderOptionsRef Options); LLVMPassBuilderOptionsRef LLVMCreatePassBuilderOptions(void); void LLVMPassBuilderOptionsSetVerifyEach(LLVMPassBuilderOptionsRef Options, LLVMBool VerifyEach); void LLVMPassBuilderOptionsSetDebugLogging(LLVMPassBuilderOptionsRef Options, LLVMBool DebugLogging); @@ -325,8 +325,8 @@ void llvm_emit_ptr_from_array(GenContext *c, BEValue *value) switch (value->type->type_kind) { case TYPE_POINTER: - llvm_value_rvalue(c, value); - value->kind = BE_ADDRESS; + llvm_value_rvalue(c, value); + value->kind = BE_ADDRESS; return; case TYPE_ARRAY: case TYPE_VECTOR: @@ -338,9 +338,9 @@ void llvm_emit_ptr_from_array(GenContext *c, BEValue *value) llvm_emit_subarray_pointer(c, value, &member); llvm_value_rvalue(c, &member); llvm_value_set_address(value, - member.value, - type_get_ptr(value->type->array.base), - type_abi_alignment(value->type->array.base)); + member.value, + type_get_ptr(value->type->array.base), + type_abi_alignment(value->type->array.base)); return; } default: @@ -416,8 +416,8 @@ void llvm_emit_global_variable_init(GenContext *c, Decl *decl) LLVMValueRef old = decl->backend_ref; LLVMValueRef global_ref = decl->backend_ref = llvm_add_global_raw(c, decl_get_extname(decl), - LLVMTypeOf(init_value), - decl->alignment); + LLVMTypeOf(init_value), + decl->alignment); if (decl->var.is_addr) { LLVMSetUnnamedAddress(global_ref, LLVMNoUnnamedAddr); @@ -425,7 +425,7 @@ void llvm_emit_global_variable_init(GenContext *c, Decl *decl) else { LLVMSetUnnamedAddress(decl->backend_ref, - decl_is_local(decl) ? LLVMGlobalUnnamedAddr : LLVMLocalUnnamedAddr); + decl_is_local(decl) ? LLVMGlobalUnnamedAddr : LLVMLocalUnnamedAddr); } if (decl->section_id) { @@ -924,9 +924,9 @@ LLVMValueRef llvm_get_opt_ref(GenContext *c, Decl *decl) static void llvm_emit_param_attributes(GenContext *c, LLVMValueRef function, ABIArgInfo *info, bool is_return, int index, int last_index) { assert(last_index == index || info->kind == ABI_ARG_DIRECT_PAIR || info->kind == ABI_ARG_IGNORE - || info->kind == ABI_ARG_EXPAND || info->kind == ABI_ARG_DIRECT || info->kind == ABI_ARG_DIRECT_COERCE - || info->kind == ABI_ARG_DIRECT_COERCE_INT || info->kind == ABI_ARG_EXPAND_COERCE - || info->kind == ABI_ARG_DIRECT_SPLIT_STRUCT_I32); + || info->kind == ABI_ARG_EXPAND || info->kind == ABI_ARG_DIRECT || info->kind == ABI_ARG_DIRECT_COERCE + || info->kind == ABI_ARG_DIRECT_COERCE_INT || info->kind == ABI_ARG_EXPAND_COERCE + || info->kind == ABI_ARG_DIRECT_SPLIT_STRUCT_I32); if (info->attributes.zeroext) { @@ -1125,7 +1125,7 @@ static void llvm_gen_test_main(GenContext *c) LLVMPositionBuilderAtEnd(builder, entry); LLVMValueRef val = LLVMBuildCall2(builder, runner_type, other_func, NULL, 0, ""); val = LLVMBuildSelect(builder, LLVMBuildTrunc(builder, val, c->bool_type, ""), - LLVMConstNull(cint), LLVMConstInt(cint, 1, false), ""); + LLVMConstNull(cint), LLVMConstInt(cint, 1, false), ""); LLVMBuildRet(builder, val); LLVMDisposeBuilder(builder); gencontext_print_llvm_ir(c); @@ -1257,10 +1257,10 @@ LLVMMetadataRef llvm_get_debug_file(GenContext *c, FileId file_id) } File *f = source_file_by_id(file_id); LLVMMetadataRef file = LLVMDIBuilderCreateFile(c->debug.builder, - f->name, - strlen(f->name), - f->dir_path, - strlen(f->dir_path)); + f->name, + strlen(f->name), + f->dir_path, + strlen(f->dir_path)); DebugFile debug_file = { .file_id = file_id, .debug_file = file }; vec_add(c->debug.debug_files, debug_file); return file; diff --git a/src/compiler/llvm_codegen_builtins.c b/src/compiler/llvm_codegen_builtins.c index f60b0cb4e..543e250c6 100644 --- a/src/compiler/llvm_codegen_builtins.c +++ b/src/compiler/llvm_codegen_builtins.c @@ -99,7 +99,7 @@ INLINE void llvm_emit_compare_exchange(GenContext *c, BEValue *result_value, Exp uint64_t failure_ordering = args[6]->const_expr.ixx.i.low; uint64_t alignment = args[7]->const_expr.ixx.i.low; LLVMValueRef result = LLVMBuildAtomicCmpXchg(c->builder, normal_args[0], normal_args[1], normal_args[2], - ordering_to_llvm(success_ordering), ordering_to_llvm(failure_ordering), false); + ordering_to_llvm(success_ordering), ordering_to_llvm(failure_ordering), false); if (alignment && alignment >= type_abi_alignment(type)) { LLVMSetAlignment(result, alignment); @@ -181,8 +181,8 @@ INLINE void llvm_emit_atomic_load(GenContext *c, BEValue *result_value, Expr *ex static inline LLVMValueRef llvm_syscall_asm(GenContext *c, LLVMTypeRef func_type, char *call) { return LLVMGetInlineAsm(func_type, call, strlen(call), - scratch_buffer_to_string(), scratch_buffer.len, - true, true, LLVMInlineAsmDialectATT, /* can throw */ false); + scratch_buffer_to_string(), scratch_buffer.len, + true, true, LLVMInlineAsmDialectATT, /* can throw */ false); } static inline void llvm_syscall_write_regs_to_scratch(const char** registers, unsigned args) diff --git a/src/compiler/llvm_codegen_debug_info.c b/src/compiler/llvm_codegen_debug_info.c index ea9c7f7c2..3ae4e0bfd 100644 --- a/src/compiler/llvm_codegen_debug_info.c +++ b/src/compiler/llvm_codegen_debug_info.c @@ -34,17 +34,17 @@ static inline LLVMMetadataRef llvm_get_debug_struct(GenContext *c, Type *type, c if (!row) row = 1; } LLVMMetadataRef real = LLVMDIBuilderCreateStructType(c->debug.builder, - scope, - external_name_len ? type->name : "", external_name_len ? strlen(type->name) : 0, - file, - row, - type_size(type) * 8, - (uint32_t)(type_abi_alignment(type) * 8), - flags, NULL, - elements, element_count, - c->debug.runtime_version, - NULL, // VTable - external_name, strlen(external_name)); + scope, + external_name_len ? type->name : "", external_name_len ? strlen(type->name) : 0, + file, + row, + type_size(type) * 8, + (uint32_t)(type_abi_alignment(type) * 8), + flags, NULL, + elements, element_count, + c->debug.runtime_version, + NULL, // VTable + external_name, strlen(external_name)); if (type->backend_debug_type) { LLVMMetadataReplaceAllUsesWith(type->backend_debug_type, real); @@ -122,17 +122,17 @@ void llvm_emit_debug_function(GenContext *c, Decl *decl) uint32_t row = decl->span.row; if (!row) row = 1; c->debug.function = LLVMDIBuilderCreateFunction(c->debug.builder, - c->debug.file.debug_file, - decl->name, strlen(decl->name), - decl->extname, strlen(decl->extname), - c->debug.file.debug_file, - row, - llvm_get_debug_type(c, decl->type), - decl_is_local(decl), - true, - row, - flags, - active_target.optimization_level != OPTIMIZATION_NONE); + c->debug.file.debug_file, + decl->name, strlen(decl->name), + decl->extname, strlen(decl->extname), + c->debug.file.debug_file, + row, + llvm_get_debug_type(c, decl->type), + decl_is_local(decl), + true, + row, + flags, + active_target.optimization_level != OPTIMIZATION_NONE); LLVMSetSubprogram(decl->backend_ref, c->debug.function); } @@ -163,11 +163,11 @@ void llvm_emit_debug_local_var(GenContext *c, Decl *decl) LLVMMetadataRef inline_at = NULL; assert(!decl->is_value); LLVMDIBuilderInsertDeclareAtEnd(c->debug.builder, - decl->backend_ref, var, - LLVMDIBuilderCreateExpression(c->debug.builder, NULL, 0), - LLVMDIBuilderCreateDebugLocation(c->context, row, col, - scope, inline_at), - LLVMGetInsertBlock(c->builder)); + decl->backend_ref, var, + LLVMDIBuilderCreateExpression(c->debug.builder, NULL, 0), + LLVMDIBuilderCreateDebugLocation(c->context, row, col, + scope, inline_at), + LLVMGetInsertBlock(c->builder)); } /** @@ -202,12 +202,12 @@ void llvm_emit_debug_parameter(GenContext *c, Decl *parameter, unsigned index) if (parameter->is_value) return; LLVMDIBuilderInsertDeclareAtEnd(c->debug.builder, - parameter->is_value ? NULL : parameter->backend_ref, - parameter->var.backend_debug_ref, - LLVMDIBuilderCreateExpression(c->debug.builder, NULL, 0), - LLVMDIBuilderCreateDebugLocation(c->context, row, col, c->debug.function, - inline_at), - LLVMGetInsertBlock(c->builder)); + parameter->is_value ? NULL : parameter->backend_ref, + parameter->var.backend_debug_ref, + LLVMDIBuilderCreateExpression(c->debug.builder, NULL, 0), + LLVMDIBuilderCreateDebugLocation(c->context, row, col, c->debug.function, + inline_at), + LLVMGetInsertBlock(c->builder)); } @@ -223,9 +223,9 @@ void llvm_emit_debug_location(GenContext *c, SourceSpan location) unsigned col = location.col; c->last_emitted_loc.a = location.a; LLVMMetadataRef loc = LLVMDIBuilderCreateDebugLocation(c->context, - row ? row : 1, - col ? col : 1, - scope, /* inlined at */ 0); + row ? row : 1, + col ? col : 1, + scope, /* inlined at */ 0); LLVMSetCurrentDebugLocation2(c->builder, loc); } @@ -239,15 +239,15 @@ static LLVMMetadataRef llvm_debug_forward_comp(GenContext *c, Type *type, const if (!row) row = 1; } return LLVMDIBuilderCreateReplaceableCompositeType(c->debug.builder, id_counter++, - type->name, strlen(type->name), - scope, - c->debug.file.debug_file, row, - 1 /* version TODO */, - type_size(type) * 8, - type_abi_alignment(type) * 8, - flags, - external_name, - strlen(external_name)); + type->name, strlen(type->name), + scope, + c->debug.file.debug_file, row, + 1 /* version TODO */, + type_size(type) * 8, + type_abi_alignment(type) * 8, + flags, + external_name, + strlen(external_name)); } void llvm_debug_push_lexical_scope(GenContext *context, SourceSpan location) @@ -271,8 +271,8 @@ void llvm_debug_push_lexical_scope(GenContext *context, SourceSpan location) } LLVMMetadataRef block = LLVMDIBuilderCreateLexicalBlock(context->debug.builder, scope, debug_file, - row ? row : 1, - col ? col : 1); + row ? row : 1, + col ? col : 1); llvm_debug_scope_push(context, block); } @@ -281,11 +281,11 @@ void llvm_debug_push_lexical_scope(GenContext *context, SourceSpan location) static LLVMMetadataRef llvm_debug_simple_type(GenContext *context, Type *type, int dwarf_code) { return type->backend_debug_type = LLVMDIBuilderCreateBasicType(context->debug.builder, - type->name, - strlen(type->name), - type->builtin.bitsize, - (LLVMDWARFTypeEncoding)dwarf_code, - LLVMDIFlagZero); + type->name, + strlen(type->name), + type->builtin.bitsize, + (LLVMDWARFTypeEncoding)dwarf_code, + LLVMDIFlagZero); } @@ -294,10 +294,10 @@ static LLVMMetadataRef llvm_debug_pointer_type(GenContext *c, Type *type) LLVMMetadataRef inner = llvm_get_debug_type(c, type->pointer); if (type->backend_debug_type) return type->backend_debug_type; return LLVMDIBuilderCreatePointerType(c->debug.builder, - inner, - type_size(type) * 8, - type_abi_alignment(type) * 8, 0, - type->name, strlen(type->name)); + inner, + type_size(type) * 8, + type_abi_alignment(type) * 8, 0, + type->name, strlen(type->name)); } static LLVMMetadataRef llvm_debug_enum_type(GenContext *c, Type *type, LLVMMetadataRef scope) @@ -327,12 +327,12 @@ static LLVMMetadataRef llvm_debug_enum_type(GenContext *c, Type *type, LLVMMetad unsigned row = decl->span.row; LLVMMetadataRef real = LLVMDIBuilderCreateEnumerationType(c->debug.builder, - scope, - type->decl->name, strlen(type->decl->name), - c->debug.file.debug_file, row ? row : 1, type_size(type) * 8, - type_abi_alignment(type) * 8, - elements, vec_size(elements), - llvm_get_debug_type(c, enum_real_type)); + scope, + type->decl->name, strlen(type->decl->name), + c->debug.file.debug_file, row ? row : 1, type_size(type) * 8, + type_abi_alignment(type) * 8, + elements, vec_size(elements), + llvm_get_debug_type(c, enum_real_type)); LLVMMetadataReplaceAllUsesWith(forward, real); return real; @@ -354,12 +354,12 @@ static LLVMMetadataRef llvm_debug_structlike_type(GenContext *c, Type *type, LLV { Decl *member = members[i]; LLVMMetadataRef debug_info = llvm_get_debug_member(c, - member->type, - member->name ? member->name : "", - member->offset, - &member->span, - forward, - LLVMDIFlagZero); + member->type, + member->name ? member->name : "", + member->offset, + &member->span, + forward, + LLVMDIFlagZero); vec_add(elements, debug_info); } @@ -368,16 +368,16 @@ static LLVMMetadataRef llvm_debug_structlike_type(GenContext *c, Type *type, LLV { unsigned row = decl->span.row; real = LLVMDIBuilderCreateUnionType(c->debug.builder, - scope, - type->decl->name ? type->decl->name : "", - type->decl->name ? strlen(type->decl->name) : 0, - c->debug.file.debug_file, row ? row : 1, type_size(type) * 8, - type_abi_alignment(type) * 8, - LLVMDIFlagZero, - elements, vec_size(members), - c->debug.runtime_version, - type->decl->name ? decl->extname : "", - type->decl->name ? strlen(decl->extname) : 0); + scope, + type->decl->name ? type->decl->name : "", + type->decl->name ? strlen(type->decl->name) : 0, + c->debug.file.debug_file, row ? row : 1, type_size(type) * 8, + type_abi_alignment(type) * 8, + LLVMDIFlagZero, + elements, vec_size(members), + c->debug.runtime_version, + type->decl->name ? decl->extname : "", + type->decl->name ? strlen(decl->extname) : 0); LLVMMetadataReplaceAllUsesWith(forward, real); return real; } @@ -452,9 +452,9 @@ static LLVMMetadataRef llvm_debug_typedef_type(GenContext *c, Type *type) if (!decl) { return LLVMDIBuilderCreateTypedef(c->debug.builder, - llvm_get_debug_type(c, type->canonical), - type->name, strlen(type->name), - NULL, 0, NULL, 0); + llvm_get_debug_type(c, type->canonical), + type->name, strlen(type->name), + NULL, 0, NULL, 0); } Type *original_type = type->type_kind == TYPE_TYPEDEF ? type->canonical : decl->distinct_decl.base_type; @@ -466,10 +466,10 @@ static LLVMMetadataRef llvm_debug_typedef_type(GenContext *c, Type *type) } unsigned row = decl->span.row; LLVMMetadataRef real = LLVMDIBuilderCreateTypedef(c->debug.builder, - llvm_get_debug_type(c, original_type), - decl->name, strlen(decl->name), - c->debug.file.debug_file, row ? row : 1, - c->debug.file.debug_file, type_abi_alignment(type)); + llvm_get_debug_type(c, original_type), + decl->name, strlen(decl->name), + c->debug.file.debug_file, row ? row : 1, + c->debug.file.debug_file, type_abi_alignment(type)); if (type->backend_debug_type) { LLVMMetadataReplaceAllUsesWith(type->backend_debug_type, real); @@ -515,9 +515,9 @@ static LLVMMetadataRef llvm_debug_func_type(GenContext *c, Type *type) vec_add(buffer, llvm_get_debug_type(c, prototype->param_types[i])); } return LLVMDIBuilderCreateSubroutineType(c->debug.builder, - c->debug.file.debug_file, - buffer, - vec_size(buffer), 0); + c->debug.file.debug_file, + buffer, + vec_size(buffer), 0); } diff --git a/src/compiler/llvm_codegen_expr.c b/src/compiler/llvm_codegen_expr.c index 749ce53ef..3edeee96a 100644 --- a/src/compiler/llvm_codegen_expr.c +++ b/src/compiler/llvm_codegen_expr.c @@ -20,7 +20,7 @@ static inline void llvm_emit_const_initialize_reference(GenContext *c, BEValue * static inline void llvm_emit_expr_block(GenContext *context, BEValue *be_value, Expr *expr); static inline void llvm_emit_optional(GenContext *c, BEValue *be_value, Expr *expr); static inline void llvm_emit_inc_dec_change(GenContext *c, BEValue *addr, BEValue *after, BEValue *before, Expr *expr, - int diff); + int diff); static inline void llvm_emit_initialize_reference(GenContext *c, BEValue *ref, Expr *expr); static inline void llvm_emit_initialize_reference_bitstruct(GenContext *c, BEValue *ref, Decl *bitstruct, Expr** elements); static inline void llvm_emit_initialize_reference_list(GenContext *c, BEValue *ref, Expr *expr); @@ -37,7 +37,7 @@ static inline void llvm_emit_vector_initializer_list(GenContext *c, BEValue *val static inline void llvm_extract_bitvalue_from_array(GenContext *c, BEValue *be_value, Decl *member, Decl *parent_decl); static inline void llvm_emit_type_from_any(GenContext *c, BEValue *be_value); static void llvm_convert_vector_comparison(GenContext *c, BEValue *be_value, LLVMValueRef val, Type *vector_type, - bool is_equals); + bool is_equals); static void llvm_emit_any_pointer(GenContext *c, BEValue *any, BEValue *pointer); static void llvm_emit_binary(GenContext *c, BEValue *be_value, Expr *expr, BEValue *lhs_loaded, BinaryOp binary_op); static void llvm_emit_call_expr(GenContext *c, BEValue *result_value, Expr *expr, BEValue *target); @@ -185,7 +185,7 @@ BEValue llvm_emit_assign_expr(GenContext *c, BEValue *ref, Expr *expr, LLVMValue } static void llvm_convert_vector_comparison(GenContext *c, BEValue *be_value, LLVMValueRef val, Type *vector_type, - bool is_equals) + bool is_equals) { unsigned bits = vector_type->array.len; LLVMTypeRef llvm_type = LLVMTypeOf(val); @@ -514,7 +514,7 @@ void llvm_emit_coerce_store(GenContext *c, LLVMValueRef addr, AlignSize alignmen LLVMTypeKind source_type_kind = LLVMGetTypeKind(target_type); LLVMTypeKind coerced_type_kind = LLVMGetTypeKind(coerced); if ((coerced_type_kind == LLVMPointerTypeKind || coerced_type_kind == LLVMIntegerTypeKind) - && (source_type_kind == LLVMPointerTypeKind || source_type_kind == LLVMIntegerTypeKind)) + && (source_type_kind == LLVMPointerTypeKind || source_type_kind == LLVMIntegerTypeKind)) { value = llvm_coerce_int_ptr(c, value, coerced, target_type); llvm_store_to_ptr_raw_aligned(c, addr, value, alignment); @@ -580,13 +580,13 @@ static void llvm_emit_array_bounds_check(GenContext *c, BEValue *index, LLVMValu if (type_is_signed(index->type)) { llvm_emit_int_comp_raw(c, &result, index->type, index->type, index->value, - llvm_get_zero(c, index->type), BINARYOP_LT); + llvm_get_zero(c, index->type), BINARYOP_LT); llvm_emit_panic_if_true(c, &result, "Negative array indexing", loc, "Negative array indexing (index was %d)", index, NULL); } llvm_emit_int_comp_raw(c, &result, index->type, index->type, - index->value, array_max_index, - BINARYOP_GE); + index->value, array_max_index, + BINARYOP_GE); BEValue max; llvm_value_set(&max, array_max_index, index->type); llvm_emit_panic_if_true(c, &result, "Array index out of bounds", loc, "Array index out of bounds (array had size %d, index was %d)", &max, index); @@ -831,7 +831,7 @@ static inline void llvm_extract_bool_bit_from_array(GenContext *c, BEValue *be_v unsigned start_bit = member->var.start_bit; // Grab the byte LLVMValueRef byte_ptr = llvm_emit_array_gep_raw(c, array_ptr, llvm_get_type(c, be_value->type), - start_bit / 8, be_value->alignment, &alignment); + start_bit / 8, be_value->alignment, &alignment); LLVMValueRef element = llvm_load(c, array_type, byte_ptr, alignment, ""); // Shift the bit to the zero position. element = llvm_emit_lshr_fixed(c, element, start_bit % 8); @@ -873,7 +873,7 @@ static inline void llvm_extract_bitvalue_from_array(GenContext *c, BEValue *be_v { AlignSize alignment; LLVMValueRef byte_ptr = llvm_emit_array_gep_raw(c, array_ptr, llvm_get_type(c, be_value->type), - (unsigned)i, be_value->alignment, &alignment); + (unsigned)i, be_value->alignment, &alignment); LLVMValueRef element = llvm_load(c, array_type, byte_ptr, alignment, ""); element = llvm_zext_trunc(c, element, llvm_member_type); int current_offset = 8 * (i - start_byte) - offset; @@ -968,12 +968,12 @@ static inline void llvm_extract_bitvalue(GenContext *c, BEValue *be_value, Expr } static inline void llvm_emit_update_bitstruct_array(GenContext *c, - LLVMValueRef array_ptr, - AlignSize array_alignment, - LLVMTypeRef array_type, - bool need_bitswap, - Decl *member, - LLVMValueRef value) + LLVMValueRef array_ptr, + AlignSize array_alignment, + LLVMTypeRef array_type, + bool need_bitswap, + Decl *member, + LLVMValueRef value) { unsigned start_bit = member->var.start_bit; unsigned end_bit = member->var.end_bit; @@ -1008,7 +1008,7 @@ static inline void llvm_emit_update_bitstruct_array(GenContext *c, { AlignSize alignment; LLVMValueRef byte_ptr = llvm_emit_array_gep_raw(c, array_ptr, array_type, - (unsigned)i, array_alignment, &alignment); + (unsigned)i, array_alignment, &alignment); if (i == start_byte && start_mod != 0) { int skipped_bits = start_mod; @@ -1069,7 +1069,7 @@ static inline void llvm_emit_bitassign_array(GenContext *c, BEValue *result, BEV { llvm_value_addr(c, &parent); llvm_emit_update_bitstruct_array(c, parent.value, parent.alignment, llvm_get_type(c, parent.type), - bitstruct_requires_bitswap(parent_decl), member, llvm_load_value_store(c, result)); + bitstruct_requires_bitswap(parent_decl), member, llvm_load_value_store(c, result)); } INLINE LLVMValueRef llvm_emit_bitstruct_value_update(GenContext *c, LLVMValueRef current_val, TypeSize bits, LLVMTypeRef bitstruct_type, Decl *member, LLVMValueRef val) @@ -1524,8 +1524,8 @@ void llvm_emit_cast(GenContext *c, CastKind cast_kind, Expr *expr, BEValue *valu case CAST_FPFP: llvm_value_rvalue(c, value); value->value = type_convert_will_trunc(to_type, from_type) - ? LLVMBuildFPTrunc(c->builder, value->value, llvm_get_type(c, to_type), "fpfptrunc") - : LLVMBuildFPExt(c->builder, value->value, llvm_get_type(c, to_type), "fpfpext"); + ? LLVMBuildFPTrunc(c->builder, value->value, llvm_get_type(c, to_type), "fpfptrunc") + : LLVMBuildFPExt(c->builder, value->value, llvm_get_type(c, to_type), "fpfpext"); break; case CAST_FPINT: llvm_value_rvalue(c, value); @@ -1590,11 +1590,11 @@ void llvm_emit_cast(GenContext *c, CastKind cast_kind, Expr *expr, BEValue *valu if (llvm_value_is_addr(value)) { value->value = llvm_emit_struct_gep_raw(c, - value->value, - llvm_get_type(c, value->type), - 1, - value->alignment, - &value->alignment); + value->value, + llvm_get_type(c, value->type), + 1, + value->alignment, + &value->alignment); } else { @@ -1623,11 +1623,11 @@ static inline void llvm_emit_cast_expr(GenContext *context, BEValue *be_value, E } llvm_emit_exprid(context, be_value, expr->cast_expr.expr); llvm_emit_cast(context, - expr->cast_expr.kind, - expr, - be_value, - expr->type, - exprtype(expr->cast_expr.expr)); + expr->cast_expr.kind, + expr, + be_value, + expr->type, + exprtype(expr->cast_expr.expr)); } @@ -1996,9 +1996,9 @@ static void llvm_emit_initialize_designated(GenContext *c, BEValue *ref, AlignSi if (ref->type->type_kind == TYPE_UNION) { llvm_value_set_address(&value, - ref->value, - type, - type_min_alignment(offset, decl_alignment)); + ref->value, + type, + type_min_alignment(offset, decl_alignment)); } else { @@ -2341,8 +2341,8 @@ static inline LLVMValueRef llvm_emit_inc_dec_value(GenContext *c, SourceSpan spa LLVMTypeRef llvm_type = llvm_get_type(c, type); LLVMValueRef diff_value = LLVMConstInt(llvm_type, 1, false); return diff > 0 - ? llvm_emit_add_int(c, type, original->value, diff_value, span) - : llvm_emit_sub_int(c, type, original->value, diff_value, span); + ? llvm_emit_add_int(c, type, original->value, diff_value, span) + : llvm_emit_sub_int(c, type, original->value, diff_value, span); } case TYPE_VECTOR: { @@ -2366,8 +2366,8 @@ static inline LLVMValueRef llvm_emit_inc_dec_value(GenContext *c, SourceSpan spa if (is_integer) { return diff > 0 - ? llvm_emit_add_int(c, type, original->value, val, span) - : llvm_emit_sub_int(c, type, original->value, val, span); + ? llvm_emit_add_int(c, type, original->value, val, span) + : llvm_emit_sub_int(c, type, original->value, val, span); } else { @@ -2379,7 +2379,7 @@ static inline LLVMValueRef llvm_emit_inc_dec_value(GenContext *c, SourceSpan spa } } static inline void llvm_emit_inc_dec_change(GenContext *c, BEValue *addr, BEValue *after, BEValue *before, Expr *expr, - int diff) + int diff) { EMIT_LOC(c, expr); Type *type = type_reduced_from_expr(expr); @@ -2636,7 +2636,7 @@ static void llvm_emit_unary_expr(GenContext *c, BEValue *value, Expr *expr) LLVMTypeRef type_to_use = llvm_get_type(c, type->canonical); LLVMValueRef args[2] = { zero, value->value }; LLVMValueRef call_res = llvm_emit_call_intrinsic(c, intrinsic_id.ssub_overflow, - &type_to_use, 1, args, 2); + &type_to_use, 1, args, 2); value->value = llvm_emit_extract_value(c, call_res, 0); LLVMValueRef ok = llvm_emit_extract_value(c, call_res, 1); llvm_emit_panic_on_true(c, ok, "Signed negation overflow", expr->span, NULL, NULL, NULL); @@ -2705,7 +2705,7 @@ void llvm_emit_len_for_expr(GenContext *c, BEValue *be_value, BEValue *expr_to_l } static void llvm_emit_trap_negative(GenContext *c, Expr *expr, LLVMValueRef value, const char *error, - BEValue *index_val) + BEValue *index_val) { if (!active_target.feature.safe_mode) return; if (type_is_integer_unsigned(expr->type->canonical)) return; @@ -3039,9 +3039,9 @@ static void llvm_emit_slice_assign(GenContext *c, BEValue *be_value, Expr *expr) bool signed_start = type_is_signed(start.type); bool signed_end = type_is_signed(end.type); uint64_t start_val = signed_start ? (uint64_t)LLVMConstIntGetSExtValue(start.value) - : (uint64_t)LLVMConstIntGetZExtValue(start.value); + : (uint64_t)LLVMConstIntGetZExtValue(start.value); uint64_t end_val = signed_end ? (uint64_t)LLVMConstIntGetSExtValue(end.value) - : (uint64_t)LLVMConstIntGetZExtValue(end.value); + : (uint64_t)LLVMConstIntGetZExtValue(end.value); assert(start_val <= INT64_MAX); assert(end_val <= INT64_MAX); if (start_val > end_val) return; @@ -3429,11 +3429,11 @@ static inline LLVMValueRef llvm_emit_mult_int(GenContext *c, Type *type, LLVMVal unsigned operation = type_is_integer_unsigned(type) ? intrinsic_id.umul_overflow : intrinsic_id.smul_overflow; LLVMValueRef call_res = llvm_emit_call_intrinsic(c, - operation, - types, - 1, - args, - 2); + operation, + types, + 1, + args, + 2); LLVMValueRef val = llvm_emit_extract_value(c, call_res, 0); LLVMValueRef ok = llvm_emit_extract_value(c, call_res, 1); llvm_emit_panic_on_true(c, ok, "Integer multiplication overflow", loc, NULL, NULL, NULL); @@ -3493,17 +3493,17 @@ static void llvm_emit_subarray_comp(GenContext *c, BEValue *be_value, BEValue *l BEValue lhs_to_compare; BEValue rhs_to_compare; llvm_value_set_address_abi_aligned(&lhs_to_compare, - llvm_emit_pointer_inbounds_gep_raw(c, - llvm_base_type, - lhs_value.value, - current_index.value), - array_base_type); + llvm_emit_pointer_inbounds_gep_raw(c, + llvm_base_type, + lhs_value.value, + current_index.value), + array_base_type); llvm_value_set_address_abi_aligned(&rhs_to_compare, - llvm_emit_pointer_inbounds_gep_raw(c, - llvm_base_type, - rhs_value.value, - current_index.value), - array_base_type); + llvm_emit_pointer_inbounds_gep_raw(c, + llvm_base_type, + rhs_value.value, + current_index.value), + array_base_type); llvm_emit_comp(c, &cmp, &lhs_to_compare, &rhs_to_compare, BINARYOP_EQ); match_fail_block = c->current_block; llvm_store_raw(c, &index_var, LLVMBuildAdd(c->builder, current_index.value, one, "")); @@ -3991,7 +3991,7 @@ void llvm_emit_binary(GenContext *c, BEValue *be_value, Expr *expr, BEValue *lhs { LLVMTypeRef int_type = llvm_get_type(c, type_isz); val = LLVMBuildSub(c->builder, LLVMBuildPtrToInt(c->builder, lhs_value, int_type, ""), - LLVMBuildPtrToInt(c->builder, rhs_value, int_type, ""), ""); + LLVMBuildPtrToInt(c->builder, rhs_value, int_type, ""), ""); val = LLVMBuildExactSDiv(c->builder, val, llvm_const_int(c, type_isz, type_abi_alignment(lhs_type->pointer)), ""); break; } @@ -4028,8 +4028,8 @@ void llvm_emit_binary(GenContext *c, BEValue *be_value, Expr *expr, BEValue *lhs break; } val = type_is_unsigned(lhs_type) - ? LLVMBuildUDiv(c->builder, lhs_value, rhs_value, "udiv") - : LLVMBuildSDiv(c->builder, lhs_value, rhs_value, "sdiv"); + ? LLVMBuildUDiv(c->builder, lhs_value, rhs_value, "udiv") + : LLVMBuildSDiv(c->builder, lhs_value, rhs_value, "sdiv"); break; case BINARYOP_MOD: llvm_emit_trap_zero(c, rhs_type, rhs_value, "% by zero.", expr->span); @@ -4039,15 +4039,15 @@ void llvm_emit_binary(GenContext *c, BEValue *be_value, Expr *expr, BEValue *lhs break; } val = type_is_unsigned(lhs_type) - ? LLVMBuildURem(c->builder, lhs_value, rhs_value, "umod") - : LLVMBuildSRem(c->builder, lhs_value, rhs_value, "smod"); + ? LLVMBuildURem(c->builder, lhs_value, rhs_value, "umod") + : LLVMBuildSRem(c->builder, lhs_value, rhs_value, "smod"); break; case BINARYOP_SHR: rhs_value = llvm_zext_trunc(c, rhs_value, LLVMTypeOf(lhs_value)); llvm_emit_trap_invalid_shift(c, rhs_value, lhs_type, "Shift amount out of range (was %s).", expr->span); val = type_is_unsigned(lhs_type) - ? LLVMBuildLShr(c->builder, lhs_value, rhs_value, "lshr") - : LLVMBuildAShr(c->builder, lhs_value, rhs_value, "ashr"); + ? LLVMBuildLShr(c->builder, lhs_value, rhs_value, "lshr") + : LLVMBuildAShr(c->builder, lhs_value, rhs_value, "ashr"); val = LLVMBuildFreeze(c->builder, val, ""); break; case BINARYOP_SHL: @@ -4111,9 +4111,9 @@ static void llvm_emit_post_unary_expr(GenContext *context, BEValue *be_value, Ex { llvm_emit_post_inc_dec(context, - be_value, - expr->unary_expr.expr, - expr->unary_expr.operator == UNARYOP_INC ? 1 : -1); + be_value, + expr->unary_expr.expr, + expr->unary_expr.operator == UNARYOP_INC ? 1 : -1); } void llvm_emit_typeid(GenContext *c, BEValue *be_value, Type *type) @@ -4764,11 +4764,11 @@ static void llvm_expand_struct_to_args(GenContext *context, Type *param_type, LL Type *member_type = members[i]->type; AlignSize load_align; LLVMValueRef member_ptr = llvm_emit_struct_gep_raw(context, - expand_ptr, - llvm_get_type(context, param_type), - i, - alignment, - &load_align); + expand_ptr, + llvm_get_type(context, param_type), + i, + alignment, + &load_align); llvm_expand_type_to_args(context, member_type, member_ptr, args, arg_count_ref, load_align); } } @@ -4796,10 +4796,10 @@ static void llvm_expand_type_to_args(GenContext *context, Type *param_type, LLVM case ALL_FLOATS: case TYPE_POINTER: args[(*arg_count_ref)++] = llvm_load(context, - llvm_get_type(context, param_type), - expand_ptr, - alignment, - "loadexpanded"); + llvm_get_type(context, param_type), + expand_ptr, + alignment, + "loadexpanded"); return; case TYPE_TYPEDEF: param_type = param_type->canonical; @@ -4830,7 +4830,7 @@ void llvm_emit_struct_member_ref(GenContext *c, BEValue *struct_ref, BEValue *me } LLVMValueRef llvm_emit_struct_gep_raw(GenContext *context, LLVMValueRef ptr, LLVMTypeRef struct_type, unsigned index, - unsigned struct_alignment, AlignSize *alignment) + unsigned struct_alignment, AlignSize *alignment) { *alignment = type_min_alignment((AlignSize)LLVMOffsetOfElement(context->target_data, struct_type, index), struct_alignment); if (llvm_is_const(ptr)) @@ -4875,11 +4875,11 @@ void llvm_emit_subarray_len(GenContext *c, BEValue *subarray, BEValue *len) llvm_value_addr(c, subarray); AlignSize alignment = 0; LLVMValueRef len_addr = llvm_emit_struct_gep_raw(c, - subarray->value, - llvm_get_type(c, subarray->type), - 1, - subarray->alignment, - &alignment); + subarray->value, + llvm_get_type(c, subarray->type), + 1, + subarray->alignment, + &alignment); llvm_value_set_address(len, len_addr, type_usz, alignment); } @@ -4928,11 +4928,11 @@ void llvm_value_struct_gep(GenContext *c, BEValue *element, BEValue *struct_poin } AlignSize alignment; LLVMValueRef ref = llvm_emit_struct_gep_raw(c, - struct_pointer->value, - llvm_get_type(c, struct_pointer->type), - (unsigned)actual_index, - struct_pointer->alignment, - &alignment); + struct_pointer->value, + llvm_get_type(c, struct_pointer->type), + (unsigned)actual_index, + struct_pointer->alignment, + &alignment); llvm_value_set_address_abi_aligned(element, ref, member->type); element->alignment = alignment; } @@ -5129,10 +5129,10 @@ void llvm_add_abi_call_attributes(GenContext *c, LLVMValueRef call_value, int co if (info->attributes.by_val) { llvm_attribute_add_call_type(c, - call_value, - attribute_id.byval, - (int)info->param_index_start + 1, - llvm_get_type(c, info->indirect.type)); + call_value, + attribute_id.byval, + (int)info->param_index_start + 1, + llvm_get_type(c, info->indirect.type)); } llvm_attribute_add_call(c, call_value, attribute_id.align, (int)info->param_index_start + 1, info->indirect.alignment); break; @@ -5173,11 +5173,11 @@ void llvm_emit_vararg_parameter(GenContext *c, BEValue *value, Type *vararg_type llvm_emit_expr(c, &temp_value, val); AlignSize store_alignment; LLVMValueRef slot = llvm_emit_array_gep_raw(c, - array_ref, - llvm_array_type, - foreach_index, - alignment, - &store_alignment); + array_ref, + llvm_array_type, + foreach_index, + alignment, + &store_alignment); llvm_store_to_ptr_aligned(c, slot, &temp_value, store_alignment); } llvm_value_aggregate_two(c, value, vararg_type, array_ref, llvm_const_int(c, type_usz, elements)); @@ -5212,9 +5212,9 @@ void llvm_emit_raw_call(GenContext *c, BEValue *result_value, FunctionPrototype if (prototype->abi_varargs) { llvm_add_abi_call_attributes(c, - call_value, - vec_size(prototype->varargs), - prototype->abi_varargs); + call_value, + vec_size(prototype->varargs), + prototype->abi_varargs); } // 11. Process the return value. @@ -5334,9 +5334,9 @@ void llvm_emit_raw_call(GenContext *c, BEValue *result_value, FunctionPrototype // Emit the current stack into the thread local or things will get messed up. if (c->debug.current_stack_ptr) llvm_store_to_ptr_raw_aligned(c, - c->debug.current_stack_ptr, - c->debug.stack_slot, - type_alloca_alignment(type_voidptr)); + c->debug.current_stack_ptr, + c->debug.stack_slot, + type_alloca_alignment(type_voidptr)); // 17a. If we used the error var as the indirect recipient, then that will hold the error. // otherwise it's whatever value in be_value. @@ -5375,9 +5375,9 @@ void llvm_emit_raw_call(GenContext *c, BEValue *result_value, FunctionPrototype // Emit the current stack into the thread local or things will get messed up. if (c->debug.current_stack_ptr) llvm_store_to_ptr_raw_aligned(c, - c->debug.current_stack_ptr, - c->debug.stack_slot, - type_alloca_alignment(type_voidptr)); + c->debug.current_stack_ptr, + c->debug.stack_slot, + type_alloca_alignment(type_voidptr)); // 17i. The simple case here is where there is a normal return. // In this case be_value already holds the result @@ -5470,11 +5470,11 @@ static LLVMValueRef llvm_emit_dynamic_search(GenContext *c, LLVMValueRef type_id } AlignSize align; LLVMValueRef dtable_ref = llvm_emit_struct_gep_raw(c, - type_id_ptr, - c->introspect_type, - INTROSPECT_INDEX_DTABLE, - llvm_abi_alignment(c, c->introspect_type), - &align); + type_id_ptr, + c->introspect_type, + INTROSPECT_INDEX_DTABLE, + llvm_abi_alignment(c, c->introspect_type), + &align); LLVMValueRef dtable_ptr = llvm_load(c, c->ptr_type, dtable_ref, align, ""); LLVMValueRef params[2] = { dtable_ptr, selector }; LLVMValueRef call = LLVMBuildCall2(c->builder, type, func, params, 2, ""); @@ -5492,9 +5492,9 @@ static void llvm_emit_call_expr(GenContext *c, BEValue *result_value, Expr *expr if (c->debug.stack_slot_row) { llvm_store_to_ptr_raw_aligned(c, - c->debug.stack_slot_row, - llvm_const_int(c, type_uint, expr->span.row), - type_abi_alignment(type_uint)); + c->debug.stack_slot_row, + llvm_const_int(c, type_uint, expr->span.row), + type_abi_alignment(type_uint)); } LLVMTypeRef func_type; @@ -5644,9 +5644,9 @@ static void llvm_emit_call_expr(GenContext *c, BEValue *result_value, Expr *expr break; } llvm_value_set_address(result_value, - llvm_emit_alloca(c, llvm_get_type(c, call_return_type), alignment, "sretparam"), - call_return_type, - alignment); + llvm_emit_alloca(c, llvm_get_type(c, call_return_type), alignment, "sretparam"), + call_return_type, + alignment); // 6c. Add the pointer to the list of arguments. arg_values[arg_count++] = result_value->value; @@ -5754,9 +5754,9 @@ static void llvm_emit_call_expr(GenContext *c, BEValue *result_value, Expr *expr if (c->debug.current_stack_ptr) { llvm_store_to_ptr_raw_aligned(c, - c->debug.current_stack_ptr, - c->debug.stack_slot, - type_alloca_alignment(type_voidptr)); + c->debug.current_stack_ptr, + c->debug.stack_slot, + type_alloca_alignment(type_voidptr)); } // 17i. The simple case here is where there is a normal return. @@ -5930,7 +5930,7 @@ static inline void llvm_emit_macro_block(GenContext *c, BEValue *be_value, Expr case VARDECL_PARAM_CT_TYPE: case VARDECL_PARAM_EXPR: continue; - case VARDECL_PARAM_REF: + case VARDECL_PARAM_REF: case VARDECL_PARAM: break; } @@ -5964,7 +5964,7 @@ static inline void llvm_emit_macro_block(GenContext *c, BEValue *be_value, Expr } LLVMValueRef llvm_emit_call_intrinsic(GenContext *context, unsigned intrinsic, LLVMTypeRef *types, unsigned type_count, - LLVMValueRef *values, unsigned arg_count) + LLVMValueRef *values, unsigned arg_count) { LLVMValueRef decl = LLVMGetIntrinsicDeclaration(context->module, intrinsic, types, type_count); LLVMTypeRef type = LLVMIntrinsicGetType(context->context, intrinsic, types, type_count); @@ -6191,18 +6191,18 @@ static inline void llvm_emit_typeid_info(GenContext *c, BEValue *value, Expr *ex BEValue check; LLVMBasicBlockRef exit = llvm_basic_block_new(c, "check_type_ok"); IntrospectType checks[8] = { INTROSPECT_TYPE_ARRAY, INTROSPECT_TYPE_POINTER, - INTROSPECT_TYPE_VECTOR, INTROSPECT_TYPE_ENUM, - INTROSPECT_TYPE_SUBARRAY, INTROSPECT_TYPE_DISTINCT, - INTROSPECT_TYPE_OPTIONAL, INTROSPECT_TYPE_SUBARRAY }; + INTROSPECT_TYPE_VECTOR, INTROSPECT_TYPE_ENUM, + INTROSPECT_TYPE_SUBARRAY, INTROSPECT_TYPE_DISTINCT, + INTROSPECT_TYPE_OPTIONAL, INTROSPECT_TYPE_SUBARRAY }; for (int i = 0; i < 8; i++) { llvm_emit_int_comp_raw(c, - &check, - type_char, - type_char, - kind, - llvm_const_int(c, type_char, checks[i]), - BINARYOP_EQ); + &check, + type_char, + type_char, + kind, + llvm_const_int(c, type_char, checks[i]), + BINARYOP_EQ); LLVMBasicBlockRef next = llvm_basic_block_new(c, "check_next"); llvm_emit_cond_br(c, &check, exit, next); llvm_emit_block(c, next); @@ -6226,12 +6226,12 @@ static inline void llvm_emit_typeid_info(GenContext *c, BEValue *value, Expr *ex for (int i = 0; i < 1; i++) { llvm_emit_int_comp_raw(c, - &check, - type_char, - type_char, - kind, - llvm_const_int(c, type_char, checks[i]), - BINARYOP_EQ); + &check, + type_char, + type_char, + kind, + llvm_const_int(c, type_char, checks[i]), + BINARYOP_EQ); LLVMBasicBlockRef next = llvm_basic_block_new(c, "check_next"); llvm_emit_cond_br(c, &check, exit, next); llvm_emit_block(c, next); @@ -6255,16 +6255,16 @@ static inline void llvm_emit_typeid_info(GenContext *c, BEValue *value, Expr *ex LLVMBasicBlockRef exit = llvm_basic_block_new(c, "check_type_ok"); IntrospectType checks[4] = { INTROSPECT_TYPE_ARRAY, INTROSPECT_TYPE_VECTOR, INTROSPECT_TYPE_ENUM, - INTROSPECT_TYPE_SUBARRAY }; + INTROSPECT_TYPE_SUBARRAY }; for (int i = 0; i < 4; i++) { llvm_emit_int_comp_raw(c, - &check, - type_char, - type_char, - kind, - llvm_const_int(c, type_char, checks[i]), - BINARYOP_EQ); + &check, + type_char, + type_char, + kind, + llvm_const_int(c, type_char, checks[i]), + BINARYOP_EQ); LLVMBasicBlockRef next = llvm_basic_block_new(c, "check_next"); llvm_emit_cond_br(c, &check, exit, next); llvm_emit_block(c, next); @@ -6378,11 +6378,11 @@ static inline void llvm_emit_type_from_any(GenContext *c, BEValue *be_value) { AlignSize alignment = 0; LLVMValueRef pointer_addr = llvm_emit_struct_gep_raw(c, - be_value->value, - llvm_get_type(c, type_any), - 1, - be_value->alignment, - &alignment); + be_value->value, + llvm_get_type(c, type_any), + 1, + be_value->alignment, + &alignment); llvm_value_set_address(be_value, pointer_addr, type_typeid, alignment); } else @@ -6429,7 +6429,7 @@ static inline void llvm_emit_builtin_access(GenContext *c, BEValue *be_value, Ex llvm_emit_cond_br(c, &check, exit_block, ok_block); llvm_emit_block(c, ok_block); LLVMValueRef fault_data = LLVMBuildIntToPtr(c->builder, be_value->value, - c->ptr_type, ""); + c->ptr_type, ""); LLVMValueRef ptr = LLVMBuildStructGEP2(c->builder, c->fault_type, fault_data, 2, ""); LLVMValueRef ordinal = llvm_load_abi_alignment(c, type_usz, ptr, ""); llvm_emit_br(c, exit_block); @@ -6479,11 +6479,11 @@ static inline void llvm_emit_builtin_access(GenContext *c, BEValue *be_value, Ex LLVMTypeRef subarray = llvm_get_type(c, type_chars); LLVMValueRef to_introspect = LLVMBuildIntToPtr(c->builder, inner_type->backend_typeid, - c->ptr_type, ""); + c->ptr_type, ""); LLVMValueRef ptr = LLVMBuildStructGEP2(c->builder, c->introspect_type, to_introspect, INTROSPECT_INDEX_ADDITIONAL, ""); LLVMValueRef val = llvm_zext_trunc(c, be_value->value, c->size_type); llvm_value_set_address(be_value, llvm_emit_pointer_gep_raw(c, subarray, ptr, val), - type_chars, llvm_abi_alignment(c, subarray)); + type_chars, llvm_abi_alignment(c, subarray)); return; } case ACCESS_TYPEOFANYFAULT: diff --git a/src/compiler/llvm_codegen_function.c b/src/compiler/llvm_codegen_function.c index c7ca45220..8d5ba6ab0 100644 --- a/src/compiler/llvm_codegen_function.c +++ b/src/compiler/llvm_codegen_function.c @@ -12,8 +12,8 @@ static void llvm_expand_from_args(GenContext *c, Type *type, LLVMValueRef ref, u static inline void llvm_process_parameter_value(GenContext *c, Decl *decl, ABIArgInfo *info, unsigned *index); static inline void llvm_emit_func_parameter(GenContext *context, Decl *decl, ABIArgInfo *abi_info, unsigned *index, unsigned real_index); static inline void llvm_emit_body(GenContext *c, LLVMValueRef function, const char *module_name, - const char *function_name, - FileId file_id, FunctionPrototype *prototype, Signature *signature, Ast *body); + const char *function_name, + FileId file_id, FunctionPrototype *prototype, Signature *signature, Ast *body); /** @@ -49,7 +49,7 @@ bool llvm_emit_check_block_branch(GenContext *c) // Consequently, we will delete those and realize that // we then have no need for emitting a br. if (!c->current_block_is_target - && !LLVMGetFirstUse(LLVMBasicBlockAsValue(c->current_block))) + && !LLVMGetFirstUse(LLVMBasicBlockAsValue(c->current_block))) { LLVMDeleteBasicBlock(c->current_block); c->current_block = NULL; @@ -190,9 +190,9 @@ static inline void llvm_process_parameter_value(GenContext *c, Decl *decl, ABIAr scratch_buffer_append("A null pointer argument was passed to a '&' parameter."); } llvm_emit_panic_on_true(c, - is_null, - scratch_buffer_to_string(), - decl->span, + is_null, + scratch_buffer_to_string(), + decl->span, NULL, NULL, NULL); } if (!decl->var.is_written && !decl->var.is_addr) @@ -413,13 +413,13 @@ void llvm_emit_function_body(GenContext *c, Decl *decl) if (decl->func_decl.attr_dynamic) vec_add(c->dynamic_functions, decl); assert(decl->backend_ref); llvm_emit_body(c, - decl->backend_ref, - decl->unit->module->name->module, - decl->name, - decl->span.file_id, - type_get_resolved_prototype(decl->type), - decl->func_decl.attr_naked ? NULL : &decl->func_decl.signature, - astptr(decl->func_decl.body)); + decl->backend_ref, + decl->unit->module->name->module, + decl->name, + decl->span.file_id, + type_get_resolved_prototype(decl->type), + decl->func_decl.attr_naked ? NULL : &decl->func_decl.signature, + astptr(decl->func_decl.body)); } void llvm_emit_stacktrace_definitions(GenContext *c) @@ -444,8 +444,8 @@ void llvm_emit_stacktrace_definitions(GenContext *c) AlignSize alignment = llvm_abi_alignment(c, slot_type); LLVMValueRef prev_ptr = llvm_emit_struct_gep_raw(c, stacktrace, slot_type, 0, alignment, &align_to_use); llvm_store_to_ptr_raw_aligned(c, prev_ptr, - LLVMBuildLoad2(c->builder, c->ptr_type, c->debug.current_stack_ptr, ""), - align_to_use); + LLVMBuildLoad2(c->builder, c->ptr_type, c->debug.current_stack_ptr, ""), + align_to_use); LLVMValueRef func_name = llvm_emit_struct_gep_raw(c, stacktrace, slot_type, 1, alignment, &align_to_use); LLVMValueRef func_name_ptr = llvm_emit_struct_gep_raw(c, func_name, c->chars_type, 0, align_to_use, &align_to_use); llvm_store_to_ptr_raw_aligned(c, func_name_ptr, LLVMGetParam(func, 1), align_to_use); @@ -458,9 +458,9 @@ void llvm_emit_stacktrace_definitions(GenContext *c) LLVMValueRef file_name_sz = llvm_emit_struct_gep_raw(c, file_name, c->chars_type, 1, align_to_use, &align_to_use); llvm_store_to_ptr_raw_aligned(c, file_name_sz, LLVMGetParam(func, 4), align_to_use); llvm_store_to_ptr_raw_aligned(c, - c->debug.current_stack_ptr, - stacktrace, - type_alloca_alignment(type_voidptr)); + c->debug.current_stack_ptr, + stacktrace, + type_alloca_alignment(type_voidptr)); LLVMValueRef line = llvm_emit_struct_gep_raw(c, stacktrace, slot_type, 3, alignment, &align_to_use); llvm_store_to_ptr_raw_aligned(c, line, LLVMGetParam(func, 5), align_to_use); LLVMBuildRetVoid(c->builder); @@ -469,7 +469,7 @@ void llvm_emit_stacktrace_definitions(GenContext *c) } void llvm_emit_body(GenContext *c, LLVMValueRef function, const char *module_name, const char *function_name, - FileId file_id, FunctionPrototype *prototype, Signature *signature, Ast *body) + FileId file_id, FunctionPrototype *prototype, Signature *signature, Ast *body) { bool emit_debug = llvm_use_debug(c); LLVMValueRef prev_function = c->function; @@ -640,27 +640,27 @@ void llvm_emit_xxlizer(GenContext *c, Decl *decl) LLVMMetadataRef type = LLVMDIBuilderCreateSubroutineType(c->debug.builder, c->debug.file.debug_file, NULL, 0, 0); c->debug.function = LLVMDIBuilderCreateFunction(c->debug.builder, - c->debug.file.debug_file, - scratch_buffer.str, scratch_buffer.len, - scratch_buffer.str, scratch_buffer.len, - c->debug.file.debug_file, + c->debug.file.debug_file, + scratch_buffer.str, scratch_buffer.len, + scratch_buffer.str, scratch_buffer.len, + c->debug.file.debug_file, row, - type, - true, + type, true, - row, - LLVMDIFlagPrivate, - active_target.optimization_level != OPTIMIZATION_NONE); + true, + row, + LLVMDIFlagPrivate, + active_target.optimization_level != OPTIMIZATION_NONE); LLVMSetSubprogram(function, c->debug.function); } llvm_emit_body(c, - function, - decl->unit->module->name->module, - is_initializer ? "[static initializer]" : "[static finalizer]", - decl->span.file_id, - NULL, - NULL, - body); + function, + decl->unit->module->name->module, + is_initializer ? "[static initializer]" : "[static finalizer]", + decl->span.file_id, + NULL, + NULL, + body); } diff --git a/src/compiler/llvm_codegen_internal.h b/src/compiler/llvm_codegen_internal.h index ccb94fbaa..367524b0d 100644 --- a/src/compiler/llvm_codegen_internal.h +++ b/src/compiler/llvm_codegen_internal.h @@ -264,7 +264,7 @@ void gencontext_end_module(GenContext *context); LLVMValueRef LLVMConstBswap(LLVMValueRef ConstantVal); #ifndef LLVMCreateTypeAttribute LLVMAttributeRef LLVMCreateTypeAttribute(LLVMContextRef C, unsigned KindID, - LLVMTypeRef type_ref); + LLVMTypeRef type_ref); #endif static inline LLVMValueRef decl_optional_ref(Decl *decl) @@ -418,7 +418,7 @@ TypeSize llvm_alloc_size(GenContext *c, LLVMTypeRef type); INLINE LLVMValueRef llvm_emit_insert_value(GenContext *c, LLVMValueRef agg, LLVMValueRef new_value, ArraySize index); LLVMValueRef llvm_emit_aggregate_two(GenContext *c, Type *type, LLVMValueRef value1, LLVMValueRef value2); LLVMValueRef llvm_emit_struct_gep_raw(GenContext *context, LLVMValueRef ptr, LLVMTypeRef struct_type, unsigned index, - unsigned struct_alignment, AlignSize *alignment); + unsigned struct_alignment, AlignSize *alignment); LLVMValueRef llvm_emit_array_gep_raw(GenContext *c, LLVMValueRef ptr, LLVMTypeRef array_type, unsigned index, AlignSize array_alignment, AlignSize *alignment); LLVMValueRef llvm_emit_array_gep_raw_index(GenContext *c, LLVMValueRef ptr, LLVMTypeRef array_type, LLVMValueRef index, AlignSize array_alignment, AlignSize *alignment); LLVMValueRef llvm_emit_pointer_gep_raw(GenContext *c, LLVMTypeRef pointee_type, LLVMValueRef ptr, LLVMValueRef offset); @@ -465,9 +465,9 @@ void llvm_emit_expr(GenContext *c, BEValue *value, Expr *expr); void llvm_emit_ignored_expr(GenContext *c, Expr *expr); void llvm_emit_stmt(GenContext *c, Ast *ast); void llvm_emit_panic_on_true(GenContext *c, LLVMValueRef value, const char *panic_name, SourceSpan loc, - const char *fmt, BEValue *value_1, BEValue *value_2); + const char *fmt, BEValue *value_1, BEValue *value_2); void llvm_emit_panic_if_true(GenContext *c, BEValue *value, const char *panic_name, SourceSpan loc, const char *fmt, BEValue *value_1, - BEValue *value_2); + BEValue *value_2); void llvm_emit_panic(GenContext *c, const char *message, SourceSpan loc, const char *fmt, BEValue *args); void llvm_emit_unreachable(GenContext *c); diff --git a/src/compiler/llvm_codegen_module.c b/src/compiler/llvm_codegen_module.c index fcb0dde69..fd60789de 100644 --- a/src/compiler/llvm_codegen_module.c +++ b/src/compiler/llvm_codegen_module.c @@ -195,25 +195,25 @@ void gencontext_init_file_emit(GenContext *c, CompilationUnit *unit) return; } unit->llvm.debug_compile_unit = LLVMDIBuilderCreateCompileUnit(c->debug.builder, - LLVMDWARFSourceLanguageC11, - unit->llvm.debug_file, - DWARF_PRODUCER_NAME, - strlen(DWARF_PRODUCER_NAME), - is_optimized, - dwarf_flags, - strlen(dwarf_flags), - runtime_version, - debug_output_file, - strlen(debug_output_file), - emission_kind, - dwo_id, - split_debug_inlining, - emit_debug_info_for_profiling, - sysroot, - strlen(sysroot), - sdk, - strlen(sdk) - ); + LLVMDWARFSourceLanguageC11, + unit->llvm.debug_file, + DWARF_PRODUCER_NAME, + strlen(DWARF_PRODUCER_NAME), + is_optimized, + dwarf_flags, + strlen(dwarf_flags), + runtime_version, + debug_output_file, + strlen(debug_output_file), + emission_kind, + dwo_id, + split_debug_inlining, + emit_debug_info_for_profiling, + sysroot, + strlen(sysroot), + sdk, + strlen(sdk) + ); } } diff --git a/src/compiler/llvm_codegen_stmt.c b/src/compiler/llvm_codegen_stmt.c index bcc5337a1..ca3866324 100644 --- a/src/compiler/llvm_codegen_stmt.c +++ b/src/compiler/llvm_codegen_stmt.c @@ -671,10 +671,10 @@ static void llvm_emit_switch_body_if_chain(GenContext *c, } static void llvm_emit_switch_jump_table(GenContext *c, - Ast **cases, - Ast *default_case, - BEValue *switch_value, - LLVMBasicBlockRef exit_block) + Ast **cases, + Ast *default_case, + BEValue *switch_value, + LLVMBasicBlockRef exit_block) { #ifdef jump_table_done c->current_block = NULL; @@ -1205,15 +1205,15 @@ static inline void llvm_emit_asm_block_stmt(GenContext *c, Ast *ast) } LLVMTypeRef asm_fn_type = LLVMFunctionType(result_type, param_types, param_count, 0); LLVMValueRef asm_fn = LLVMGetInlineAsm(asm_fn_type, - (char*)data, - strlen(data), + (char*)data, + strlen(data), clobbers, strlen(clobbers), - ast->asm_block_stmt.is_volatile, - true, - ast->asm_block_stmt.is_string ? LLVMInlineAsmDialectIntel : LLVMInlineAsmDialectATT, + ast->asm_block_stmt.is_volatile, + true, + ast->asm_block_stmt.is_string ? LLVMInlineAsmDialectIntel : LLVMInlineAsmDialectATT, /* can throw */ false - ); + ); LLVMValueRef res = LLVMBuildCall2(c->builder, asm_fn_type, asm_fn, args, param_count, ""); for (unsigned i = 0; i < param_count; i++) { @@ -1298,9 +1298,9 @@ void llvm_emit_panic(GenContext *c, const char *message, SourceSpan loc, const c if (c->debug.stack_slot_row) { llvm_store_to_ptr_raw_aligned(c, - c->debug.stack_slot_row, - llvm_const_int(c, type_uint, loc.row ? loc.row : 1), - type_abi_alignment(type_uint)); + c->debug.stack_slot_row, + llvm_const_int(c, type_uint, loc.row ? loc.row : 1), + type_abi_alignment(type_uint)); } Decl *panic_var = c->panic_var; @@ -1346,11 +1346,11 @@ void llvm_emit_panic(GenContext *c, const char *message, SourceSpan loc, const c { AlignSize store_alignment; LLVMValueRef slot = llvm_emit_array_gep_raw(c, - array_ref, - llvm_array_type, - i, - alignment, - &store_alignment); + array_ref, + llvm_array_type, + i, + alignment, + &store_alignment); llvm_store_to_ptr_aligned(c, slot, &varargs[i], store_alignment); } BEValue value; @@ -1361,7 +1361,7 @@ void llvm_emit_panic(GenContext *c, const char *message, SourceSpan loc, const c BEValue res; if (c->debug.builder) llvm_emit_debug_location(c, loc); llvm_emit_raw_call(c, &res, prototype, llvm_func_type(c, prototype), llvm_get_ref(c, panicf), actual_args, - count, 0, NULL, false, NULL); + count, 0, NULL, false, NULL); return; } @@ -1372,11 +1372,11 @@ void llvm_emit_panic(GenContext *c, const char *message, SourceSpan loc, const c BEValue res; if (c->debug.builder) llvm_emit_debug_location(c, loc); llvm_emit_raw_call(c, &res, prototype, llvm_func_type(c, prototype), val.value, actual_args, - count, 0, NULL, false, NULL); + count, 0, NULL, false, NULL); } void llvm_emit_panic_if_true(GenContext *c, BEValue *value, const char *panic_name, SourceSpan loc, const char *fmt, BEValue *value_1, - BEValue *value_2) + BEValue *value_2) { if (llvm_is_const(value->value)) { @@ -1407,7 +1407,7 @@ void llvm_emit_panic_if_true(GenContext *c, BEValue *value, const char *panic_na } void llvm_emit_panic_on_true(GenContext *c, LLVMValueRef value, const char *panic_name, SourceSpan loc, - const char *fmt, BEValue *value_1, BEValue *value_2) + const char *fmt, BEValue *value_1, BEValue *value_2) { BEValue be_value; llvm_value_set(&be_value, value, type_bool); diff --git a/src/compiler/llvm_codegen_storeload.c b/src/compiler/llvm_codegen_storeload.c index 8528a8a90..a9ab56cad 100644 --- a/src/compiler/llvm_codegen_storeload.c +++ b/src/compiler/llvm_codegen_storeload.c @@ -48,11 +48,11 @@ LLVMValueRef llvm_store_to_ptr_aligned(GenContext *c, LLVMValueRef destination, ByteSize size = type_size(value->type); LLVMValueRef copy_size = llvm_const_int(c, size <= UINT32_MAX ? type_uint : type_usz, size); LLVMValueRef copy = LLVMBuildMemCpy(c->builder, - destination, - alignment, - value->value, - value->alignment ? value->alignment : type_abi_alignment(value->type), - copy_size); + destination, + alignment, + value->value, + value->alignment ? value->alignment : type_abi_alignment(value->type), + copy_size); return copy; } } diff --git a/src/compiler/llvm_codegen_type.c b/src/compiler/llvm_codegen_type.c index d05058202..96e6c32e7 100644 --- a/src/compiler/llvm_codegen_type.c +++ b/src/compiler/llvm_codegen_type.c @@ -432,7 +432,7 @@ static inline LLVMValueRef llvm_generate_temp_introspection_global(GenContext *c } static inline LLVMValueRef llvm_generate_introspection_global(GenContext *c, LLVMValueRef original_global, Type *type, IntrospectType introspect_type, - Type *inner, size_t len, LLVMValueRef additional, bool is_external) + Type *inner, size_t len, LLVMValueRef additional, bool is_external) { if (original_global) { @@ -538,7 +538,7 @@ static LLVMValueRef llvm_get_introspection_for_enum(GenContext *c, Type *type) llvm_emit_expr(c, &value, enum_vals[i]->enum_constant.args[ai]); assert(!llvm_value_is_addr(&value)); LLVMValueRef llvm_value = llvm_value_is_bool(&value) ? LLVMBuildZExt(c->builder, value.value, c->byte_type, "") - : value.value; + : value.value; values[i] = llvm_value; if (!val_type) { @@ -555,9 +555,9 @@ static LLVMValueRef llvm_get_introspection_for_enum(GenContext *c, Type *type) scratch_buffer_append("$"); scratch_buffer_append(associated_value->name); LLVMValueRef global_ref = llvm_add_global_raw(c, - scratch_buffer_to_string(), - LLVMTypeOf(associated_value_arr), - 0); + scratch_buffer_to_string(), + LLVMTypeOf(associated_value_arr), + 0); llvm_set_linkonce(c, global_ref); LLVMSetInitializer(global_ref, associated_value_arr); LLVMSetGlobalConstant(global_ref, true); @@ -604,8 +604,8 @@ static LLVMValueRef llvm_get_introspection_for_fault(GenContext *c, Type *type) LLVMSetGlobalConstant(global_name, 1); LLVMValueRef vals[3] = { LLVMBuildPtrToInt(c->builder, ref, c->typeid_type, ""), - llvm_emit_string_const(c, val->name, ".fault"), - llvm_const_int(c, type_usz, val->enum_constant.ordinal + 1 )}; + llvm_emit_string_const(c, val->name, ".fault"), + llvm_const_int(c, type_usz, val->enum_constant.ordinal + 1 )}; LLVMSetInitializer(global_name, llvm_get_struct_named(c->fault_type, vals, 3)); llvm_set_linkonce(c, global_name); @@ -669,17 +669,17 @@ LLVMValueRef llvm_get_typeid(GenContext *c, Type *type) return llvm_get_introspection_for_builtin_type(c, type, INTROSPECT_TYPE_BOOL, 0); case ALL_SIGNED_INTS: return llvm_get_introspection_for_builtin_type(c, type, INTROSPECT_TYPE_SIGNED_INT, - type_kind_bitsize(type->type_kind)); + type_kind_bitsize(type->type_kind)); case ALL_UNSIGNED_INTS: return llvm_get_introspection_for_builtin_type(c, - type, - INTROSPECT_TYPE_UNSIGNED_INT, - type_kind_bitsize(type->type_kind)); + type, + INTROSPECT_TYPE_UNSIGNED_INT, + type_kind_bitsize(type->type_kind)); case ALL_FLOATS: return llvm_get_introspection_for_builtin_type(c, - type, - INTROSPECT_TYPE_FLOAT, - type_kind_bitsize(type->type_kind)); + type, + INTROSPECT_TYPE_FLOAT, + type_kind_bitsize(type->type_kind)); case TYPE_ANYFAULT: return llvm_get_introspection_for_builtin_type(c, type, INTROSPECT_TYPE_ANYFAULT, 0); case TYPE_ANY: diff --git a/src/compiler/llvm_codegen_value.c b/src/compiler/llvm_codegen_value.c index c3d67b795..56fb296a0 100644 --- a/src/compiler/llvm_codegen_value.c +++ b/src/compiler/llvm_codegen_value.c @@ -90,10 +90,10 @@ void llvm_value_rvalue(GenContext *c, BEValue *value) } llvm_value_fold_optional(c, value); value->value = llvm_load(c, - llvm_get_type(c, value->type), - value->value, - value->alignment ? value->alignment : type_abi_alignment(value->type), - ""); + llvm_get_type(c, value->type), + value->value, + value->alignment ? value->alignment : type_abi_alignment(value->type), + ""); if (value->type->type_kind == TYPE_BOOL) { value->value = llvm_emit_trunc_bool(c, value->value); diff --git a/src/compiler/parse_expr.c b/src/compiler/parse_expr.c index 96df2ab8c..82eb4d0ba 100644 --- a/src/compiler/parse_expr.c +++ b/src/compiler/parse_expr.c @@ -410,7 +410,7 @@ static Expr *parse_lambda(ParseContext *c, Expr *left) if (tok_is(c, TOKEN_IMPLIES)) { ASSIGN_ASTID_OR_RET(func->func_decl.body, - parse_short_body(c, func->func_decl.signature.rtype, false), poisoned_expr); + parse_short_body(c, func->func_decl.signature.rtype, false), poisoned_expr); } else if (tok_is(c, TOKEN_LBRACE)) { @@ -446,7 +446,7 @@ Expr *parse_vasplat(ParseContext *c) * parameter ::= (param_path '=')? expr */ bool parse_arg_list(ParseContext *c, Expr ***result, TokenType param_end, bool *splat, bool vasplat, - bool allow_trailing_comma) + bool allow_trailing_comma) { *result = NULL; if (splat) *splat = false; @@ -1430,7 +1430,7 @@ EXIT: if (type_bits) { type_base = is_unsigned ? type_int_unsigned_by_bitsize((unsigned)type_bits) - : type_int_signed_by_bitsize((unsigned)type_bits); + : type_int_signed_by_bitsize((unsigned)type_bits); } else { @@ -1460,12 +1460,12 @@ EXIT: if (type_bits) { SEMA_ERROR_HERE("'%s' does not fit in a '%c%d' literal.", - i128_to_string(i, radix, true), is_unsigned ? 'u' : 'i', type_bits); + i128_to_string(i, radix, true), is_unsigned ? 'u' : 'i', type_bits); } else { SEMA_ERROR_HERE("'%s' does not fit in an %s literal.", - i128_to_string(i, radix, true), is_unsigned ? "unsigned int" : "int"); + i128_to_string(i, radix, true), is_unsigned ? "unsigned int" : "int"); } return poisoned_expr; } diff --git a/src/compiler/parse_global.c b/src/compiler/parse_global.c index e3490c6db..ce9f880f6 100644 --- a/src/compiler/parse_global.c +++ b/src/compiler/parse_global.c @@ -1162,7 +1162,7 @@ INLINE bool is_end_of_param_list(ParseContext *c) * | ELLIPSIS (CT_TYPE_IDENT | non_type_ident ('=' expr)?)? */ bool parse_parameters(ParseContext *c, Decl ***params_ref, Decl **body_params, - Variadic *variadic, int *vararg_index_ref, ParameterParseKind parse_kind) + Variadic *variadic, int *vararg_index_ref, ParameterParseKind parse_kind) { Decl** params = NULL; bool var_arg_found = false; @@ -1702,7 +1702,7 @@ static inline Decl *parse_def_type(ParseContext *c) if (token_is_any_type(c->tok)) { SEMA_ERROR_HERE("'%s' is the name of a built-in type and can't be used as an alias.", - token_type_to_string(c->tok)); + token_type_to_string(c->tok)); return poisoned_decl; } if (token_is_some_ident(c->tok)) @@ -2050,7 +2050,7 @@ static inline Decl *parse_macro_declaration(ParseContext *c, AstId docs) if (tok_is(c, TOKEN_IMPLIES)) { ASSIGN_ASTID_OR_RET(decl->func_decl.body, - parse_short_body(c, decl->func_decl.signature.rtype, true), poisoned_decl); + parse_short_body(c, decl->func_decl.signature.rtype, true), poisoned_decl); return decl; } ASSIGN_ASTID_OR_RET(decl->func_decl.body, parse_compound_stmt(c), poisoned_decl); @@ -2268,7 +2268,7 @@ static inline Decl *parse_func_definition(ParseContext *c, AstId contracts, bool if (tok_is(c, TOKEN_IMPLIES)) { ASSIGN_ASTID_OR_RET(func->func_decl.body, - parse_short_body(c, func->func_decl.signature.rtype, true), poisoned_decl); + parse_short_body(c, func->func_decl.signature.rtype, true), poisoned_decl); } else if (tok_is(c, TOKEN_LBRACE)) { diff --git a/src/compiler/parse_stmt.c b/src/compiler/parse_stmt.c index 2bc292b49..6343e99ce 100644 --- a/src/compiler/parse_stmt.c +++ b/src/compiler/parse_stmt.c @@ -1327,7 +1327,7 @@ Ast *parse_stmt(ParseContext *c) case TOKEN_CT_INCLUDE: case TOKEN_LGENPAR: SEMA_ERROR_HERE("Unexpected '%s' found when expecting a statement.", - token_type_to_string(c->tok)); + token_type_to_string(c->tok)); advance(c); return poisoned_ast; case TOKEN_RPAREN: diff --git a/src/compiler/parser_internal.h b/src/compiler/parser_internal.h index 7c6b641db..0d2385c7d 100644 --- a/src/compiler/parser_internal.h +++ b/src/compiler/parser_internal.h @@ -62,7 +62,7 @@ bool parse_parameters(ParseContext *c, Decl ***params_ref, Decl **body_params, Variadic *variadic, int *vararg_index_ref, ParameterParseKind parse_kind); bool parse_arg_list(ParseContext *c, Expr ***result, TokenType param_end, bool *splat, bool vasplat, - bool allow_trailing_comma); + bool allow_trailing_comma); Expr *parse_type_compound_literal_expr_after_type(ParseContext *c, TypeInfo *type_info); INLINE void add_decl_to_list(Decl ***list, Decl *decl) diff --git a/src/compiler/sema_asm.c b/src/compiler/sema_asm.c index 5aa734bd1..9801afa17 100644 --- a/src/compiler/sema_asm.c +++ b/src/compiler/sema_asm.c @@ -344,7 +344,7 @@ static inline bool sema_check_asm_var(SemaContext *context, AsmInlineBlock *bloc unsigned bits = arg_bits_max(arg_type.ireg_bits, 0); assert(bits); SEMA_ERROR(expr, "%s is not supported in this position, convert it to a valid type, like %s.", - type_quoted_error_string(decl->type), type_quoted_error_string(type_int_signed_by_bitsize(bits))); + type_quoted_error_string(decl->type), type_quoted_error_string(type_int_signed_by_bitsize(bits))); return false; } return true; @@ -364,7 +364,7 @@ static inline bool sema_check_asm_var(SemaContext *context, AsmInlineBlock *bloc if (!sema_reg_float_suported_type(arg_type, type)) { SEMA_ERROR(expr, "%s is not supported in this position, convert it to a valid type.", - type_quoted_error_string(decl->type)); + type_quoted_error_string(decl->type)); return false; } return true; diff --git a/src/compiler/sema_builtins.c b/src/compiler/sema_builtins.c index fff0246e6..bed5bd075 100644 --- a/src/compiler/sema_builtins.c +++ b/src/compiler/sema_builtins.c @@ -87,7 +87,7 @@ static bool sema_check_builtin_args(Expr **args, BuiltinArg *arg_type, size_t ar case BA_FLOATLIKE: if (type_flat_is_floatlike(type)) continue; RETURN_SEMA_ERROR(arg, "Expected a floating point or floating point vector, but was %s.", - type_quoted_error_string(type)); + type_quoted_error_string(type)); case BA_VEC: if (type->type_kind == TYPE_VECTOR) continue; RETURN_SEMA_ERROR(arg, "Expected a vector."); @@ -203,8 +203,8 @@ static bool sema_expr_analyse_compare_exchange(SemaContext *context, Expr *expr) Expr *align = args[7]; if (!sema_analyse_expr_rhs(context, type_usz, align, false)) return false; if (!expr_is_const_int(align) - || !int_fits(align->const_expr.ixx, TYPE_U64) - || (!is_power_of_two(align->const_expr.ixx.i.low) && align->const_expr.ixx.i.low)) + || !int_fits(align->const_expr.ixx, TYPE_U64) + || (!is_power_of_two(align->const_expr.ixx.i.low) && align->const_expr.ixx.i.low)) { RETURN_SEMA_ERROR(args[7], "Expected a constant power-of-two alignment or zero."); } @@ -332,8 +332,8 @@ bool sema_expr_analyse_builtin_call(SemaContext *context, Expr *expr) case BUILTIN_OVERFLOW_SUB: assert(arg_count == 3); if (!sema_check_builtin_args(args, - (BuiltinArg[]) { BA_INTEGER, BA_INTEGER, BA_POINTER }, - 3)) return false; + (BuiltinArg[]) { BA_INTEGER, BA_INTEGER, BA_POINTER }, + 3)) return false; if (!sema_check_builtin_args_match(args, 2)) return false; if (type_no_optional(args[0]->type->canonical) != type_no_optional(args[2]->type->canonical->pointer)) { @@ -543,7 +543,7 @@ bool sema_expr_analyse_builtin_call(SemaContext *context, Expr *expr) case BUILTIN_FSHR: assert(arg_count == 3); if (!sema_check_builtin_args(args, (BuiltinArg[]) { BA_INTLIKE, BA_INTLIKE, BA_INTLIKE }, - 3)) return false; + 3)) return false; if (!sema_check_builtin_args_match(args, 3)) return false; rtype = args[0]->type; break; diff --git a/src/compiler/sema_casts.c b/src/compiler/sema_casts.c index 1ca07cd31..d4bf5ecba 100644 --- a/src/compiler/sema_casts.c +++ b/src/compiler/sema_casts.c @@ -346,7 +346,7 @@ static bool integer_to_integer(Expr *expr, Type *canonical, Type *type) // Fold pointer casts if narrowing // So (int)(uptr)&x => (int)&x in the backend. if (expr->expr_kind == EXPR_CAST && expr->cast_expr.kind == CAST_PTRINT - && type_size(type) <= type_size(expr->type)) + && type_size(type) <= type_size(expr->type)) { expr->type = type; return true; @@ -644,8 +644,8 @@ void cast_to_int_to_max_bit_size(SemaContext *context, Expr *lhs, Expr *rhs, Typ if (bit_size_left < bit_size_right) { Type *to = lhs->type->type_kind < TYPE_U8 - ? type_int_signed_by_bitsize(bit_size_right) - : type_int_unsigned_by_bitsize(bit_size_right); + ? type_int_signed_by_bitsize(bit_size_right) + : type_int_unsigned_by_bitsize(bit_size_right); bool success = cast(lhs, to); assert(success); return; @@ -653,8 +653,8 @@ void cast_to_int_to_max_bit_size(SemaContext *context, Expr *lhs, Expr *rhs, Typ // Rhs is smaller, do the same thing as above but with the rhs. Type *to = rhs->type->type_kind < TYPE_U8 - ? type_int_signed_by_bitsize(bit_size_left) - : type_int_unsigned_by_bitsize(bit_size_left); + ? type_int_signed_by_bitsize(bit_size_left) + : type_int_unsigned_by_bitsize(bit_size_left); bool success = cast(rhs, to); assert(success); } @@ -954,9 +954,9 @@ static bool cast_from_pointer(SemaContext *context, Expr *expr, Type *from, Type if (type_size(to_type) < type_size(type_uptr)) { SEMA_ERROR(expr, "Casting %s to %s is not allowed because '%s' is smaller than a pointer. " - "Use (%s)(iptr) if you want this lossy cast.", - type_quoted_error_string(expr->type), type_quoted_error_string(to_type), - type_to_error_string(to_type), type_to_error_string(to_type)); + "Use (%s)(iptr) if you want this lossy cast.", + type_quoted_error_string(expr->type), type_quoted_error_string(to_type), + type_to_error_string(to_type), type_to_error_string(to_type)); return false; } return cast_with_optional(expr, to_type, add_optional); @@ -986,7 +986,7 @@ static bool cast_from_pointer(SemaContext *context, Expr *expr, Type *from, Type if (!is_explicit) { would_work_explicit = cast_from_pointer(context, expr_copy(expr), - from, to, to_type, add_optional, true, true); + from, to, to_type, add_optional, true, true); } return sema_error_cannot_convert(expr, to_type, would_work_explicit, false); } @@ -1025,12 +1025,12 @@ static void sema_error_const_int_out_of_range(Expr *expr, Expr *problem, Type *t { SEMA_ERROR(problem, "The ordinal '%d' is out of range for %s, so you need an explicit cast to truncate the value.", expr->const_expr.enum_err_val->var.index, - type_quoted_error_string(to_type)); + type_quoted_error_string(to_type)); return; } const char *error_value = expr->const_expr.is_hex ? int_to_str(expr->const_expr.ixx, 16) : expr_const_to_error_string(&expr->const_expr); SEMA_ERROR(problem, "The value '%s' is out of range for %s, so you need an explicit cast to truncate the value.", error_value, - type_quoted_error_string(to_type)); + type_quoted_error_string(to_type)); } @@ -1138,15 +1138,15 @@ static inline bool sema_error_cannot_convert(Expr *expr, Type *to, bool may_cast if (may_cast_explicit) { SEMA_ERROR(expr, - "Implicitly casting %s to %s is not permitted, but you can do an explicit cast by placing '(%s)' before the expression.", - type_quoted_error_string(type_no_optional(expr->type)), - type_quoted_error_string(to), - type_to_error_string(type_no_optional(to))); + "Implicitly casting %s to %s is not permitted, but you can do an explicit cast by placing '(%s)' before the expression.", + type_quoted_error_string(type_no_optional(expr->type)), + type_quoted_error_string(to), + type_to_error_string(type_no_optional(to))); } else { SEMA_ERROR(expr, - "It is not possible to convert %s to %s.", + "It is not possible to convert %s to %s.", type_quoted_error_string(type_no_optional(expr->type)), type_quoted_error_string(to)); } return false; @@ -1406,7 +1406,7 @@ RETRY: { if (silent) return false; SEMA_ERROR(expr, "You cannot cast from a type smaller than %s.", - type_quoted_error_string(type_iptr)); + type_quoted_error_string(type_iptr)); return false; } goto CAST; @@ -1464,7 +1464,7 @@ RETRY: { if (silent) return false; SEMA_ERROR(expr, "The value '%s' is out of range for %s, so you need an explicit cast to truncate the value.", expr_const_to_error_string(&expr->const_expr), - type_quoted_error_string(to_type)); + type_quoted_error_string(to_type)); return false; } // Otherwise, check if the underlying code may narrow. @@ -1517,14 +1517,14 @@ CAST: * 3. Constant pointer conversions */ static bool cast_expr_inner(SemaContext *context, Expr *expr, Type *to_type, bool is_explicit, bool silent, - bool may_not_be_optional) + bool may_not_be_optional) { Type *from_type = expr->type; assert(!type_is_optional(to_type) || may_not_be_optional); if (to_type->canonical->type_kind == TYPE_POINTER && from_type->canonical->type_kind != TYPE_POINTER - && to_type->canonical->pointer == from_type->canonical && expr->expr_kind == EXPR_IDENTIFIER + && to_type->canonical->pointer == from_type->canonical && expr->expr_kind == EXPR_IDENTIFIER && expr->identifier_expr.was_ref) { RETURN_SEMA_ERROR(expr, "A macro ref parameter is a dereferenced pointer ('*&foo'). You can prefix it" @@ -1579,7 +1579,7 @@ static bool cast_expr_inner(SemaContext *context, Expr *expr, Type *to_type, boo { if (silent) return false; SEMA_ERROR(expr, "A 'void!' can only be cast into %s using an explicit cast. You can try using (%s)", - type_quoted_error_string(to_type), type_to_error_string(to_type)); + type_quoted_error_string(to_type), type_to_error_string(to_type)); return false; } cast(expr, to_type); @@ -1677,7 +1677,7 @@ static bool cast_expr_inner(SemaContext *context, Expr *expr, Type *to_type, boo goto CAST_FAILED; case TYPE_TYPEID: if (!type_is_pointer_sized_or_more(to_type)) goto CAST_FAILED; - goto CAST_IF_EXPLICIT; + goto CAST_IF_EXPLICIT; case TYPE_OPTIONAL: case TYPE_TYPEDEF: UNREACHABLE; @@ -1725,10 +1725,10 @@ CAST_IF_EXPLICIT: { if (silent) return false; SEMA_ERROR(expr, - "Implicitly casting %s to %s is not permitted, but you can do an explicit cast by placing '(%s)' before the expression.", - type_quoted_error_string(type_no_optional(from_type)), - type_quoted_error_string(type_no_optional(to_type)), - type_to_error_string(to_type)); + "Implicitly casting %s to %s is not permitted, but you can do an explicit cast by placing '(%s)' before the expression.", + type_quoted_error_string(type_no_optional(from_type)), + type_quoted_error_string(type_no_optional(to_type)), + type_to_error_string(to_type)); return false; } return cast(expr, to_type); diff --git a/src/compiler/sema_decls.c b/src/compiler/sema_decls.c index b6314fb34..5bc3d6e50 100644 --- a/src/compiler/sema_decls.c +++ b/src/compiler/sema_decls.c @@ -38,9 +38,9 @@ static inline bool sema_analyse_doc_header(AstId doc, Decl **params, Decl **extr static const char *attribute_domain_to_string(AttributeDomain domain); static bool sema_analyse_attribute(SemaContext *context, Decl *decl, Attr *attr, AttributeDomain domain, bool *erase_decl); static bool sema_analyse_attributes_inner(SemaContext *context, Decl *decl, Attr **attrs, AttributeDomain domain, - Decl *top, bool *erase_decl); + Decl *top, bool *erase_decl); static bool sema_analyse_attributes(SemaContext *context, Decl *decl, Attr **attrs, AttributeDomain domain, - bool *erase_decl); + bool *erase_decl); static bool sema_analyse_attributes_for_var(SemaContext *context, Decl *decl, bool *erase_decl); static bool sema_check_section(SemaContext *context, Attr *attr); static inline bool sema_analyse_attribute_decl(SemaContext *c, Decl *decl); @@ -53,7 +53,7 @@ static inline bool sema_analyse_distinct(SemaContext *context, Decl *decl); static CompilationUnit *unit_copy(Module *module, CompilationUnit *unit); static bool sema_analyse_parameterized_define(SemaContext *c, Decl *decl); static Module *module_instantiate_generic(SemaContext *context, Module *module, Path *path, Expr **params, - SourceSpan from); + SourceSpan from); static inline bool sema_analyse_enum_param(SemaContext *context, Decl *param, bool *has_default); static inline bool sema_analyse_enum(SemaContext *context, Decl *decl, bool *erase_decl); @@ -529,7 +529,7 @@ static inline bool sema_analyse_bitstruct_member(SemaContext *context, Decl *dec if (!type_is_integer(member_type) && member_type != type_bool) { SEMA_ERROR(member->var.type_info, "%s is not supported in a bitstruct, only enums, integer and boolean values may be used.", - type_quoted_error_string(member->type)); + type_quoted_error_string(member->type)); return false; } @@ -629,7 +629,7 @@ static inline bool sema_analyse_bitstruct_member(SemaContext *context, Decl *dec if (bitsize_type < bits_available) { SEMA_ERROR(member, "The bit width of %s (%d) is less than the assigned bits (%d), try reducing the range.", - type_quoted_error_string(member->type), (int)bitsize_type, (int)bits_available); + type_quoted_error_string(member->type), (int)bitsize_type, (int)bits_available); return false; } @@ -675,7 +675,7 @@ static bool sema_analyse_bitstruct(SemaContext *context, Decl *decl, bool *erase if (!type_is_integer(base_type)) { SEMA_ERROR(decl->bitstruct.base_type, "The type of the bitstruct cannot be %s but must be an integer or an array of integers.", - type_quoted_error_string(decl->bitstruct.base_type->type)); + type_quoted_error_string(decl->bitstruct.base_type->type)); return false; } Decl **members = decl->bitstruct.members; @@ -748,7 +748,7 @@ static inline bool sema_analyse_signature(SemaContext *context, Signature *sig, case VARDECL_PARAM_REF: inferred_type = type_get_ptr(method_parent->type); if (!is_macro) param->var.kind = VARDECL_PARAM; - break; + break; case VARDECL_PARAM: inferred_type = method_parent->type; break; @@ -803,7 +803,7 @@ static inline bool sema_analyse_signature(SemaContext *context, Signature *sig, if (param->var.type_info && !type_is_pointer(param->type)) { SEMA_ERROR(param->var.type_info, "A pointer type was expected for a ref argument, did you mean %s?", - type_quoted_error_string(type_get_ptr(param->type))); + type_quoted_error_string(type_get_ptr(param->type))); return decl_poison(param); } FALLTHROUGH; @@ -1157,9 +1157,9 @@ static inline bool sema_analyse_enum(SemaContext *context, Decl *decl, bool *era if (!int_fits(val, flat_underlying_type->type_kind)) { SEMA_ERROR(enum_value, - "The enum value would implicitly be %s which does not fit in %s.", - i128_to_string(value, 10, type_is_signed(flat_underlying_type)), - type_quoted_error_string(type)); + "The enum value would implicitly be %s which does not fit in %s.", + i128_to_string(value, 10, type_is_signed(flat_underlying_type)), + type_quoted_error_string(type)); return false; } enum_value->enum_constant.ordinal = value.low; @@ -1466,7 +1466,7 @@ static inline bool unit_add_method_like(CompilationUnit *unit, Type *parent_type if (method) { SEMA_ERROR(method_like, "This %s is already defined for '%s'.", - method_name_by_decl(method_like), parent_type->name); + method_name_by_decl(method_like), parent_type->name); SEMA_NOTE(method, "The previous definition was here."); return false; } @@ -1937,7 +1937,7 @@ static bool sema_analyse_attribute(SemaContext *context, Decl *decl, Attr *attr, // TODO consider doing this evaluation early, it should be possible. static bool sema_analyse_attributes_inner(SemaContext *context, Decl *decl, Attr **attrs, AttributeDomain domain, - Decl *top, bool *erase_decl) + Decl *top, bool *erase_decl) { // Detect cycles of the type @Foo = @BarCyclic, @BarCyclic = @BarCyclic if (context->macro_call_depth > 1024) @@ -2028,7 +2028,7 @@ ERR: } static bool sema_analyse_attributes(SemaContext *context, Decl *decl, Attr **attrs, AttributeDomain domain, - bool *erase_decl) + bool *erase_decl) { return sema_analyse_attributes_inner(context, decl, attrs, domain, NULL, erase_decl); } @@ -2124,8 +2124,8 @@ static inline MainType sema_find_main_type(SemaContext *context, Signature *sig, if (arg_type != type_cint) { SEMA_ERROR(params[0], - "Expected a parameter of type %s for a C-style main.", - type_quoted_error_string(type_cint)); + "Expected a parameter of type %s for a C-style main.", + type_quoted_error_string(type_cint)); return MAIN_TYPE_ERROR; } if (arg_type2 != type_get_ptr(type_get_ptr(type_char))) @@ -2156,7 +2156,7 @@ static inline MainType sema_find_main_type(SemaContext *context, Signature *sig, if (type_flatten(params[2]->type) != type_cint) { SEMA_ERROR(params[2], "Expected a parameter of type %s for the 'showCmd' parameter.", - type_quoted_error_string(type_cint)); + type_quoted_error_string(type_cint)); return MAIN_TYPE_ERROR; } if (!is_win32) @@ -2395,20 +2395,20 @@ REGISTER_MAIN: static inline bool sema_analyse_func_macro(SemaContext *context, Decl *decl, bool is_func, bool *erase_decl) { if (!sema_analyse_attributes(context, - decl, - decl->attributes, - is_func ? ATTR_FUNC : ATTR_MACRO, - erase_decl)) return decl_poison(decl); + decl, + decl->attributes, + is_func ? ATTR_FUNC : ATTR_MACRO, + erase_decl)) return decl_poison(decl); return true; } static inline bool sema_analyse_xxlizer(SemaContext *context, Decl *decl, bool *erase_decl) { if (!sema_analyse_attributes(context, - decl, - decl->attributes, - decl->decl_kind == DECL_INITIALIZE ? ATTR_INITIALIZER : ATTR_FINALIZER, - erase_decl)) return decl_poison(decl); + decl, + decl->attributes, + decl->decl_kind == DECL_INITIALIZE ? ATTR_INITIALIZER : ATTR_FINALIZER, + erase_decl)) return decl_poison(decl); if (*erase_decl) return true; if (decl->xxlizer.priority == 0) decl->xxlizer.priority = MAX_PRIORITY; context->call_env = (CallEnv) { .kind = decl->decl_kind == DECL_INITIALIZE ? CALL_ENV_INITIALIZER : CALL_ENV_FINALIZER }; @@ -2584,7 +2584,7 @@ static inline bool sema_is_valid_method_param(SemaContext *context, Decl *param, if (param_type->type_kind == TYPE_POINTER && param_type->pointer == parent_type) return true; ERROR: SEMA_ERROR(param, "The first parameter must be of type %s or %s.", type_quoted_error_string(parent_type), - type_quoted_error_string(type_get_ptr(parent_type))); + type_quoted_error_string(type_get_ptr(parent_type))); return false; } @@ -2596,8 +2596,8 @@ static bool sema_analyse_macro_method(SemaContext *context, Decl *decl) if (!type_may_have_method(parent_type)) { SEMA_ERROR(parent_type_info, - "Methods can not be associated with '%s'", - type_to_error_string(parent_type)); + "Methods can not be associated with '%s'", + type_to_error_string(parent_type)); return false; } if (!vec_size(decl->func_decl.signature.params)) @@ -2713,7 +2713,7 @@ bool sema_analyse_decl_type(SemaContext *context, Type *type, SourceSpan span) case TYPE_MEMBER: case TYPE_TYPEINFO: sema_error_at(span, "The variable cannot have an compile time %s type.", - type_quoted_error_string(type)); + type_quoted_error_string(type)); return false; default: break; @@ -2722,7 +2722,7 @@ bool sema_analyse_decl_type(SemaContext *context, Type *type, SourceSpan span) if (type == type_wildcard_optional || type->optional == type_void) { sema_error_at(span, "The use of 'void!' as a variable type is not permitted, use %s instead.", - type_quoted_error_string(type_anyfault)); + type_quoted_error_string(type_anyfault)); return false; } return true; @@ -3005,7 +3005,7 @@ static CompilationUnit *unit_copy(Module *module, CompilationUnit *unit) } static Module *module_instantiate_generic(SemaContext *context, Module *module, Path *path, Expr **params, - SourceSpan from) + SourceSpan from) { unsigned decls = 0; Decl* params_decls[MAX_PARAMS]; @@ -3104,7 +3104,7 @@ static bool sema_append_generate_parameterized_name(SemaContext *c, Module *modu { if (!sema_analyse_ct_expr(c, param)) return false; Type *type = param->type->canonical; - bool is_enum_like = type_kind_is_enumlike(type->type_kind); + bool is_enum_like = type_kind_is_enumlike(type->type_kind); if (!type_is_integer_or_bool_kind(type) && !is_enum_like) { SEMA_ERROR(param, "Only integer, bool, fault and enum values may be generic arguments."); @@ -3123,13 +3123,13 @@ static bool sema_append_generate_parameterized_name(SemaContext *c, Module *modu } } else if (is_enum_like) - { - Decl *enum_like = param->const_expr.enum_err_val; - type_mangle_introspect_name_to_buffer(enum_like->type->canonical); - scratch_buffer_append(mangled ? "_" : ":"); - scratch_buffer_append(enum_like->name); - } - else + { + Decl *enum_like = param->const_expr.enum_err_val; + type_mangle_introspect_name_to_buffer(enum_like->type->canonical); + scratch_buffer_append(mangled ? "_" : ":"); + scratch_buffer_append(enum_like->name); + } + else { char *maybe_neg = &scratch_buffer.str[scratch_buffer.len]; if (type->type_kind == TYPE_I128 || type->type_kind == TYPE_U128) @@ -3186,8 +3186,8 @@ static bool sema_analyse_generic_module_contracts(SemaContext *c, Module *module if (ast->contract.contract.comment) { sema_error_at(error_span, - "Parameter(s) would violate constraint: %s.", - ast->contract.contract.comment); + "Parameter(s) would violate constraint: %s.", + ast->contract.contract.comment); } else { @@ -3270,9 +3270,9 @@ Decl *sema_analyse_parameterized_identifier(SemaContext *c, Path *decl_path, con { assert(vec_size(params)); sema_error_at(extend_span_with_token(params[0]->span, vectail(params)->span), - "The generic module expected %d arguments, but you supplied %d, did you make a mistake?", - parameter_count, - vec_size(params)); + "The generic module expected %d arguments, but you supplied %d, did you make a mistake?", + parameter_count, + vec_size(params)); return poisoned_decl; } scratch_buffer_clear(); diff --git a/src/compiler/sema_errors.c b/src/compiler/sema_errors.c index c583462df..3f9136a0c 100644 --- a/src/compiler/sema_errors.c +++ b/src/compiler/sema_errors.c @@ -14,7 +14,7 @@ bool sema_type_error_on_binop(Expr *expr) { const char *c = token_type_to_string(binaryop_to_token(expr->binary_expr.operator)); SEMA_ERROR(expr, "%s is not defined in the expression %s %s %s.", - c, type_quoted_error_string(exprptr(expr->binary_expr.left)->type), - c, type_quoted_error_string(exprptr(expr->binary_expr.right)->type)); + c, type_quoted_error_string(exprptr(expr->binary_expr.left)->type), + c, type_quoted_error_string(exprptr(expr->binary_expr.right)->type)); return false; } diff --git a/src/compiler/sema_expr.c b/src/compiler/sema_expr.c index 4cea1111b..14b53d7fb 100644 --- a/src/compiler/sema_expr.c +++ b/src/compiler/sema_expr.c @@ -129,13 +129,13 @@ static inline bool sema_expr_analyse_var_call(SemaContext *context, Expr *expr, static inline bool sema_expr_analyse_func_call(SemaContext *context, Expr *expr, Decl *decl, Expr *struct_var, bool optional); static inline bool sema_call_analyse_invocation(SemaContext *context, Expr *call, CalledDecl callee, bool *optional); static inline bool sema_call_analyse_func_invocation(SemaContext *context, Type *type, Expr *expr, Expr *struct_var, - bool optional, const char *name); + bool optional, const char *name); static inline bool sema_call_check_invalid_body_arguments(SemaContext *context, Expr *call, CalledDecl *callee); INLINE bool sema_call_expand_arguments(SemaContext *context, CalledDecl *callee, Expr *call, Expr **args, - unsigned func_param_count, Variadic variadic, unsigned vararg_index, - bool *optional, - Expr ***varargs_ref, - Expr **vararg_splat_ref); + unsigned func_param_count, Variadic variadic, unsigned vararg_index, + bool *optional, + Expr ***varargs_ref, + Expr **vararg_splat_ref); static inline int sema_call_find_index_of_named_parameter(SemaContext *context, Decl **func_params, Expr *expr); static inline bool sema_call_check_contract_param_match(SemaContext *context, Decl *param, Expr *expr); static bool sema_call_analyse_body_expansion(SemaContext *macro_context, Expr *call); @@ -152,13 +152,13 @@ static inline bool sema_analyse_expr_dispatch(SemaContext *context, Expr *expr); static Decl *sema_expr_analyse_var_path(SemaContext *context, Expr *expr); static inline bool sema_expr_analyse_decl_element(SemaContext *context, DesignatorElement *element, Type *type, Decl **member_ref, ArraySize *index_ref, Type **return_type, unsigned i, SourceSpan loc, - bool *is_missing); + bool *is_missing); static Type *sema_expr_check_type_exists(SemaContext *context, TypeInfo *type_info); static inline Expr *sema_ct_checks_exprlist_compiles(SemaContext *context, Expr *exprlist); static inline bool sema_cast_ct_ident_rvalue(SemaContext *context, Expr *expr); static bool sema_expr_rewrite_to_typeid_property(SemaContext *context, Expr *expr, Expr *typeid, const char *kw); static bool sema_expr_rewrite_to_type_property(SemaContext *context, Expr *expr, Type *type, TypeProperty property, - Type *parent_type); + Type *parent_type); static bool sema_expr_rewrite_typeid_call(Expr *expr, Expr *typeid, TypeIdInfoKind kind, Type *result_type); static inline void sema_expr_rewrite_typeid_kind(Expr *expr, Expr *parent); static inline void sema_expr_replace_with_enum_array(Expr *enum_array_expr, Decl *enum_decl); @@ -172,7 +172,7 @@ static inline bool sema_create_const_min(SemaContext *context, Expr *expr, Type static inline bool sema_create_const_max(SemaContext *context, Expr *expr, Type *type, Type *flat); static inline bool sema_create_const_params(SemaContext *context, Expr *expr, Type *type); static inline void sema_create_const_membersof(SemaContext *context, Expr *expr, Type *type, AlignSize alignment, - AlignSize offset); + AlignSize offset); void expr_insert_widening_type(Expr *expr, Type *infer_type); static inline int64_t expr_get_index_max(Expr *expr); static inline bool expr_both_any_integer_or_integer_vector(Expr *left, Expr *right); @@ -241,7 +241,7 @@ Expr *sema_expr_analyse_ct_arg_index(SemaContext *context, Expr *index_expr, uns SEMA_ERROR(index_expr, "Only %u vararg%s exist.", args, args == 1 ? "" : "s"); return poisoned_expr; } - if (index_ref) *index_ref = (unsigned)index_val.i.low; + if (index_ref) *index_ref = (unsigned)index_val.i.low; return context->macro_varargs[(size_t)index_val.i.low]; } @@ -804,7 +804,7 @@ static inline bool sema_expr_analyse_ternary(SemaContext *context, Expr *expr) if (!max) { SEMA_ERROR(expr, "Cannot find a common parent type of '%s' and '%s'", - type_to_error_string(left->type), type_to_error_string(right->type)); + type_to_error_string(left->type), type_to_error_string(right->type)); return false; } Type *no_fail_max = type_no_optional(max); @@ -1170,10 +1170,10 @@ static inline bool sema_call_check_invalid_body_arguments(SemaContext *context, INLINE bool sema_call_expand_arguments(SemaContext *context, CalledDecl *callee, Expr *call, Expr **args, - unsigned func_param_count, Variadic variadic, unsigned vararg_index, - bool *optional, - Expr ***varargs_ref, - Expr **vararg_splat_ref) + unsigned func_param_count, Variadic variadic, unsigned vararg_index, + bool *optional, + Expr ***varargs_ref, + Expr **vararg_splat_ref) { unsigned num_args = vec_size(args); Decl **params = callee->params; @@ -1245,7 +1245,7 @@ INLINE bool sema_call_expand_arguments(SemaContext *context, CalledDecl *callee, if (i < num_args - 1) { SEMA_ERROR(arg, - "This looks like a variable argument before an splatted variable which isn't allowed. Did you add too many arguments?"); + "This looks like a variable argument before an splatted variable which isn't allowed. Did you add too many arguments?"); return false; } *vararg_splat_ref = arg; @@ -1258,7 +1258,7 @@ INLINE bool sema_call_expand_arguments(SemaContext *context, CalledDecl *callee, if (type_is_invalid_storage_type(type) || type == type_void) { SEMA_ERROR(arg, "A value of type %s cannot be passed as a variadic argument.", - type_quoted_error_string(type)); + type_quoted_error_string(type)); return false; } expr_insert_addr(arg); @@ -1420,7 +1420,7 @@ static inline bool sema_call_analyse_invocation(SemaContext *context, Expr *call { assert(call->call_expr.arguments); SEMA_ERROR(call->call_expr.arguments[num_args - 1], - "Using the splat operator is only allowed on vararg parameters."); + "Using the splat operator is only allowed on vararg parameters."); return false; } } @@ -1442,13 +1442,13 @@ static inline bool sema_call_analyse_invocation(SemaContext *context, Expr *call Expr **varargs = NULL; Expr *vararg_splat = NULL; if (!sema_call_expand_arguments(context, - &callee, - call, - args, - param_count, - variadic, - vararg_index, - optional, &varargs, &vararg_splat)) return false; + &callee, + call, + args, + param_count, + variadic, + vararg_index, + optional, &varargs, &vararg_splat)) return false; args = call->call_expr.arguments; num_args = vec_size(args); @@ -1472,7 +1472,7 @@ static inline bool sema_call_analyse_invocation(SemaContext *context, Expr *call if (type_is_invalid_storage_type(val->type) || val->type == type_void) { SEMA_ERROR(val, "A value of type %s cannot be passed as a variadic argument.", - type_quoted_error_string(val->type)); + type_quoted_error_string(val->type)); return false; } if (!cast_promote_vararg(val)) return false; @@ -1503,8 +1503,8 @@ static inline bool sema_call_analyse_invocation(SemaContext *context, Expr *call if (!expr_may_splat_as_vararg(vararg_splat, variadic_type)) { SEMA_ERROR(vararg_splat, "It's not possible to splat %s as vararg of type %s", - type_quoted_error_string(vararg_splat->type), - type_quoted_error_string(variadic_type)); + type_quoted_error_string(vararg_splat->type), + type_quoted_error_string(variadic_type)); return false; } *optional |= IS_OPTIONAL(vararg_splat); @@ -1621,7 +1621,7 @@ static inline bool sema_call_analyse_invocation(SemaContext *context, Expr *call } static inline bool sema_call_analyse_func_invocation(SemaContext *context, Type *type, Expr *expr, Expr *struct_var, - bool optional, const char *name) + bool optional, const char *name) { Signature *sig = type->function.signature; CalledDecl callee = { @@ -1724,7 +1724,7 @@ static inline Type *context_unify_returns(SemaContext *context) if (!max) { SEMA_ERROR(return_stmt, "Cannot find a common parent type of %s and %s", - type_quoted_error_string(rtype), type_quoted_error_string(common_type)); + type_quoted_error_string(rtype), type_quoted_error_string(common_type)); Ast *prev = context->returns[i - 1]; assert(prev); SEMA_NOTE(prev, "The previous return was here."); @@ -1776,11 +1776,11 @@ static inline bool sema_expr_analyse_func_call(SemaContext *context, Expr *expr, if (struct_var && decl->func_decl.attr_interface) expr->call_expr.is_dynamic_dispatch = true; return sema_call_analyse_func_invocation(context, - decl->type, - expr, - struct_var, - optional, - decl->name); + decl->type, + expr, + struct_var, + optional, + decl->name); } @@ -1876,8 +1876,8 @@ bool sema_expr_analyse_macro_call(SemaContext *context, Expr *call_expr, Expr *s if (declare_type != body_arg->type->canonical) { SEMA_ERROR(body_arg->var.type_info, "This parameter should be %s but was %s", - type_quoted_error_string(declare_type), - type_quoted_error_string(body_arg->type)); + type_quoted_error_string(declare_type), + type_quoted_error_string(body_arg->type)); return false; } } @@ -2159,7 +2159,7 @@ bool sema_expr_analyse_general_call(SemaContext *context, Expr *expr, Decl *decl if (decl == NULL) { return sema_expr_analyse_var_call(context, expr, - type_flatten(exprptr(expr->call_expr.function)->type), optional); + type_flatten(exprptr(expr->call_expr.function)->type), optional); } switch (decl->decl_kind) { @@ -2300,9 +2300,9 @@ static bool sema_slice_len_is_in_range(SemaContext *context, Type *type, Expr *l if (len_val > len) { SEMA_ERROR(len_expr, - is_vector ? "Length out of bounds, was %lld, exceeding vector length %lld." - : "Array length out of bounds, was %lld, exceeding array length %lld.", - (long long)len_val, (long long)len); + is_vector ? "Length out of bounds, was %lld, exceeding vector length %lld." + : "Array length out of bounds, was %lld, exceeding array length %lld.", + (long long)len_val, (long long)len); return false; } return true; @@ -2374,8 +2374,8 @@ static bool sema_slice_index_is_in_range(SemaContext *context, Type *type, Expr if (idx == 0 && !end_index) { SEMA_ERROR(index_expr, - "Array index out of bounds, index from end (%lld) must be greater than zero or it will exceed the max array index.", - (long long) idx); + "Array index out of bounds, index from end (%lld) must be greater than zero or it will exceed the max array index.", + (long long) idx); return false; } return true; @@ -2516,20 +2516,20 @@ static inline bool sema_expr_analyse_subscript(SemaContext *context, Expr *expr, if (start_from_end) { SEMA_ERROR(index, - size > 1 - ? "An index of '%lld' from the end is out of range, a value between 1 and %lld was expected." - : "An index of '%lld' from the end is out of range, a value of %lld was expected.", - (long long)(size - index_value), - (long long)size); + size > 1 + ? "An index of '%lld' from the end is out of range, a value between 1 and %lld was expected." + : "An index of '%lld' from the end is out of range, a value of %lld was expected.", + (long long)(size - index_value), + (long long)size); } else { SEMA_ERROR(index, - size > 1 - ? "An index of '%lld' is out of range, a value between 0 and %lld was expected." - : "An index of '%lld' is out of range, a value of %lld was expected.", - (long long)index_value, - (long long)size - 1); + size > 1 + ? "An index of '%lld' is out of range, a value between 0 and %lld was expected." + : "An index of '%lld' is out of range, a value of %lld was expected.", + (long long)index_value, + (long long)size - 1); } return false; } @@ -2567,14 +2567,14 @@ static inline bool sema_expr_analyse_subscript(SemaContext *context, Expr *expr, { // Maybe there is a [] overload? if (sema_expr_find_index_type_or_overload_for_subscript(context, - subscripted, - SUBSCRIPT_EVAL_VALUE, - &index_type, - &overload)) + subscripted, + SUBSCRIPT_EVAL_VALUE, + &index_type, + &overload)) { SEMA_ERROR(expr, - "A function or macro with '@operator(&[])' is not defined for %s, so you need && to take the address of the temporary.", - type_quoted_error_string(subscripted->type)); + "A function or macro with '@operator(&[])' is not defined for %s, so you need && to take the address of the temporary.", + type_quoted_error_string(subscripted->type)); return false; } } @@ -2984,7 +2984,7 @@ static inline bool sema_expr_analyse_type_access(SemaContext *context, Expr *exp if (ambiguous) { SEMA_ERROR(expr, "'%s' is an ambiguous name and so cannot be resolved, it may refer to method defined in '%s' or one in '%s'", - name, member->unit->module->name->module, ambiguous->unit->module->name->module); + name, member->unit->module->name->module, ambiguous->unit->module->name->module); return false; } } @@ -3045,8 +3045,8 @@ static inline bool sema_expr_analyse_member_access(SemaContext *context, Expr *e return true; case TYPE_PROPERTY_ALIGNOF: expr_rewrite_const_int(expr, type_usz, - type_min_alignment(parent->const_expr.member.offset, - parent->const_expr.member.align)); + type_min_alignment(parent->const_expr.member.offset, + parent->const_expr.member.align)); return true; case TYPE_PROPERTY_MEMBERSOF: sema_create_const_membersof(context, expr, decl->type->canonical, parent->const_expr.member.align, parent->const_expr.member.offset); @@ -3288,7 +3288,7 @@ static inline bool sema_create_const_associated(SemaContext *context, Expr *expr } static inline void sema_create_const_membersof(SemaContext *context, Expr *expr, Type *type, AlignSize alignment, - AlignSize offset) + AlignSize offset) { Decl **members = NULL; if (type_is_union_or_strukt(type)) @@ -3507,7 +3507,7 @@ EVAL: } static bool sema_expr_rewrite_to_type_property(SemaContext *context, Expr *expr, Type *type, TypeProperty property, - Type *parent_type) + Type *parent_type) { assert(type == type->canonical); if (property == TYPE_PROPERTY_NONE) return false; @@ -3917,7 +3917,7 @@ CHECK_DEEPER: if (ambiguous) { SEMA_ERROR(expr, "'%s' is an ambiguous name and so cannot be resolved, it may refer to method defined in '%s' or one in '%s'", - kw, method->unit->module->name->module, ambiguous->unit->module->name->module); + kw, method->unit->module->name->module, ambiguous->unit->module->name->module); return false; } if (!method) @@ -4606,8 +4606,8 @@ static bool sema_expr_analyse_add_sub_assign(SemaContext *context, Expr *expr, E if (!type_is_integer(right->type->canonical)) { SEMA_ERROR(right, "The right side was '%s' but only integers are valid on the right side of %s when the left side is a pointer.", - type_to_error_string(right->type), - token_type_to_string(binaryop_to_token(expr->binary_expr.operator))); + type_to_error_string(right->type), + token_type_to_string(binaryop_to_token(expr->binary_expr.operator))); return false; } return true; @@ -4653,7 +4653,7 @@ static bool sema_binary_arithmetic_promotion(SemaContext *context, Expr *left, E return false; } return cast_implicit(context, left, max) && - cast_implicit(context, right, max); + cast_implicit(context, right, max); } static void sema_binary_unify_voidptr(Expr *left, Expr *right, Type **left_type_ref, Type **right_type_ref) @@ -4702,7 +4702,7 @@ static bool sema_expr_analyse_enum_add_sub(SemaContext *context, Expr *expr, Exp SEMA_ERROR(expr, is_sub ? "Cannot subtract %s from %s" : "Cannot add %s to %s", type_quoted_error_string(left->type), - type_quoted_error_string(right->type)); + type_quoted_error_string(right->type)); return false; } Type *underlying_type = left_type->decl->enums.type_info->type; @@ -4791,7 +4791,7 @@ static bool sema_expr_analyse_sub(SemaContext *context, Expr *expr, Expr *left, if (expr_both_const(left, right) && sema_constant_fold_ops(left)) { expr_rewrite_const_int(expr, type_isz, (left->const_expr.ptr - right->const_expr.ptr) / - type_size(left_type->pointer)); + type_size(left_type->pointer)); return true; } // 3b. Set the type @@ -4867,12 +4867,12 @@ static bool sema_expr_analyse_sub(SemaContext *context, Expr *expr, Expr *left, // 7. Attempt arithmetic promotion, to promote both to a common type. if (!sema_binary_arithmetic_promotion(context, - left, - right, - left_type, - right_type, - expr, - "The subtraction %s - %s is not possible.")) + left, + right, + left_type, + right_type, + expr, + "The subtraction %s - %s is not possible.")) { return false; } @@ -4940,8 +4940,8 @@ static bool sema_expr_analyse_add(SemaContext *context, Expr *expr, Expr *left, if (!type_is_integer(right_type)) { SEMA_ERROR(right, "A value of type '%s' cannot be added to '%s', an integer was expected here.", - type_to_error_string(right->type), - type_to_error_string(left->type)); + type_to_error_string(right->type), + type_to_error_string(left->type)); return false; } @@ -5003,12 +5003,12 @@ static bool sema_expr_analyse_add(SemaContext *context, Expr *expr, Expr *left, assert(!cast_to_iptr); // 4. Do a binary arithmetic promotion if (!sema_binary_arithmetic_promotion(context, - left, - right, - left_type, - right_type, - expr, - "Cannot do the addition %s + %s.")) + left, + right, + left_type, + right_type, + expr, + "Cannot do the addition %s + %s.")) { return false; } @@ -5381,7 +5381,7 @@ static bool sema_binary_is_unsigned_always_false_comparison(SemaContext *context return false; case BINARYOP_GE: SEMA_ERROR(left, - "Comparing '0 >= unsigned expression' is the same as 0 == expr and is a common bug, " + "Comparing '0 >= unsigned expression' is the same as 0 == expr and is a common bug, " "so is only allowed inside of macro expansions."); return false; default: @@ -5399,12 +5399,12 @@ static bool sema_binary_is_unsigned_always_false_comparison(SemaContext *context { case BINARYOP_LT: SEMA_ERROR(right, - "Comparing 'unsigned expression < 0' can never be true, and is only allowed inside of macro expansions."); + "Comparing 'unsigned expression < 0' can never be true, and is only allowed inside of macro expansions."); return false; case BINARYOP_LE: SEMA_ERROR(right, "Comparing 'unsigned expression <= 0' is the same as expr == 0 and is a common bug, " - "so is only allowed inside of macro expansions."); + "so is only allowed inside of macro expansions."); return false; default: return true; @@ -5455,7 +5455,7 @@ static bool sema_expr_analyse_comp(SemaContext *context, Expr *expr, Expr *left, if (type_is_integer(left_vec) && type_is_integer(right_vec)) goto DONE; } SEMA_ERROR(expr, "Vector types %s and %s cannot be compared.", - type_quoted_error_string(left->type), type_quoted_error_string(right->type)); + type_quoted_error_string(left->type), type_quoted_error_string(right->type)); return false; } @@ -5466,7 +5466,7 @@ static bool sema_expr_analyse_comp(SemaContext *context, Expr *expr, Expr *left, if (!max) { SEMA_ERROR(expr, "%s and %s are different types and cannot be compared.", - type_quoted_error_string(left->type), type_quoted_error_string(right->type)); + type_quoted_error_string(left->type), type_quoted_error_string(right->type)); return false; } @@ -5475,12 +5475,12 @@ static bool sema_expr_analyse_comp(SemaContext *context, Expr *expr, Expr *left, if (type_is_user_defined(max->canonical)) { SEMA_ERROR(expr, "%s does not support comparisons, you need to manually implement a comparison if you need it.", - type_quoted_error_string(left->type)); + type_quoted_error_string(left->type)); } else { SEMA_ERROR(expr, "%s does not support comparisons.", - type_quoted_error_string(left->type)); + type_quoted_error_string(left->type)); } return false; } @@ -5489,7 +5489,7 @@ static bool sema_expr_analyse_comp(SemaContext *context, Expr *expr, Expr *left, if (!type_is_ordered(max)) { SEMA_ERROR(expr, "%s can only be compared using '!=' and '==' it cannot be ordered, did you make a mistake?", - type_quoted_error_string(left->type)); + type_quoted_error_string(left->type)); return false; } if (type_flatten(max)->type_kind == TYPE_POINTER) @@ -5700,7 +5700,7 @@ static inline bool sema_expr_analyse_addr(SemaContext *context, Expr *expr) { Expr *parent = inner->access_expr.parent; if (parent->expr_kind == EXPR_TYPEINFO) break; - if (!sema_analyse_expr_lvalue_fold_const(context, parent)) return false; + if (!sema_analyse_expr_lvalue_fold_const(context, parent)) return false; break; } default: @@ -5966,7 +5966,7 @@ static inline bool sema_expr_analyse_taddr(SemaContext *context, Expr *expr) if (type_is_invalid_storage_type(type) || type == type_void) { SEMA_ERROR(expr, "It is not possible to take the address from a value of type %s.", - type_quoted_error_string(type)); + type_quoted_error_string(type)); return false; } // 2. The type is the resulting type of the expression. @@ -6521,7 +6521,7 @@ RETRY: } static inline bool sema_expr_analyse_decl_element(SemaContext *context, DesignatorElement *element, Type *type, Decl **member_ref, ArraySize *index_ref, Type **return_type, unsigned i, SourceSpan loc, - bool *is_missing) + bool *is_missing) { DesignatorType kind = element->kind; if (kind == DESIGNATOR_RANGE) @@ -6647,7 +6647,7 @@ static inline bool sema_expr_analyse_decl_element(SemaContext *context, Designat if (ambiguous) { sema_error_at(loc, "'%s' is an ambiguous name and so cannot be resolved, it may refer to method defined in '%s' or one in '%s'", - kw, member->unit->module->name->module, ambiguous->unit->module->name->module); + kw, member->unit->module->name->module, ambiguous->unit->module->name->module); return false; } if (is_missing) @@ -6689,14 +6689,14 @@ static inline bool sema_expr_analyse_ct_alignof(SemaContext *context, Expr *expr ArraySize index = 0; Type *result_type; if (!sema_expr_analyse_decl_element(context, - element, - type, - &member, - &index, - &result_type, - i, - i == 0 ? main_var->span : expr->span, - NULL)) return false; + element, + type, + &member, + &index, + &result_type, + i, + i == 0 ? main_var->span : expr->span, + NULL)) return false; if (member) { align = type_min_alignment(member->offset, align); @@ -6799,8 +6799,8 @@ RETRY: if (!type_is_valid_for_vector(type)) { SEMA_ERROR(type_info->array.base, - "%s cannot be vectorized. Only integers, floats and booleans are allowed.", - type_quoted_error_string(type)); + "%s cannot be vectorized. Only integers, floats and booleans are allowed.", + type_quoted_error_string(type)); return poisoned_type; } return type_get_vector(type, size); @@ -7254,14 +7254,14 @@ RETRY: Type *ret_type; bool missing = false; if (!sema_expr_analyse_decl_element(context, - element, - type, - &member, - &index, - &ret_type, - i, - i == 0 ? main_var->span : expr->span, - &missing)) + element, + type, + &member, + &index, + &ret_type, + i, + i == 0 ? main_var->span : expr->span, + &missing)) { if (missing) goto NOT_DEFINED; return false; @@ -7293,12 +7293,12 @@ static inline bool sema_expr_analyse_ct_arg(SemaContext *context, Expr *expr) return true; case TOKEN_CT_VAARG: { - unsigned index; + unsigned index; // A normal argument, this means we only evaluate it once. ASSIGN_EXPR_OR_RET(Expr *arg_expr, sema_expr_analyse_ct_arg_index(context, exprptr(expr->ct_arg_expr.arg), &index), false); - index++; - assert(index < 0x10000); + index++; + assert(index < 0x10000); Decl *decl = NULL; // Try to find the original param. FOREACH_BEGIN(Decl *val, context->macro_params) @@ -7314,7 +7314,7 @@ static inline bool sema_expr_analyse_ct_arg(SemaContext *context, Expr *expr) { decl = decl_new_generated_var(arg_expr->type, VARDECL_PARAM, arg_expr->span); decl->var.init_expr = arg_expr; - decl->va_index = (uint16_t)index; + decl->va_index = (uint16_t)index; vec_add(context->macro_params, decl); } // Replace with the identifier. @@ -7332,7 +7332,7 @@ static inline bool sema_expr_analyse_ct_arg(SemaContext *context, Expr *expr) case TOKEN_CT_VACONST: { // An expr argument, this means we copy and evaluate. - ASSIGN_EXPR_OR_RET(Expr *arg_expr, sema_expr_analyse_ct_arg_index(context, exprptr(expr->ct_arg_expr.arg), NULL), false); + ASSIGN_EXPR_OR_RET(Expr *arg_expr, sema_expr_analyse_ct_arg_index(context, exprptr(expr->ct_arg_expr.arg), NULL), false); arg_expr = copy_expr_single(arg_expr); if (!expr_is_constant_eval(arg_expr, CONSTANT_EVAL_CONSTANT_VALUE)) { @@ -7345,12 +7345,12 @@ static inline bool sema_expr_analyse_ct_arg(SemaContext *context, Expr *expr) case TOKEN_CT_VAREF: { // A normal argument, this means we only evaluate it once. - unsigned index; + unsigned index; ASSIGN_EXPR_OR_RET(Expr *arg_expr, sema_expr_analyse_ct_arg_index(context, exprptr(expr->ct_arg_expr.arg), &index), false); if (!sema_binary_is_expr_lvalue(arg_expr, arg_expr)) return false; - index++; - assert(index < 0x10000); + index++; + assert(index < 0x10000); Decl *decl = NULL; // Try to find the original param. @@ -7365,11 +7365,11 @@ static inline bool sema_expr_analyse_ct_arg(SemaContext *context, Expr *expr) // Not found, so generate a new. if (!decl) { - arg_expr = copy_expr_single(arg_expr); - expr_insert_addr(arg_expr); - decl = decl_new_generated_var(arg_expr->type, VARDECL_PARAM_REF, arg_expr->span); - decl->var.init_expr = arg_expr; - decl->va_index = (uint16_t)index; + arg_expr = copy_expr_single(arg_expr); + expr_insert_addr(arg_expr); + decl = decl_new_generated_var(arg_expr->type, VARDECL_PARAM_REF, arg_expr->span); + decl->var.init_expr = arg_expr; + decl->va_index = (uint16_t)index; vec_add(context->macro_params, decl); } // Replace with the identifier. @@ -7435,14 +7435,14 @@ static inline bool sema_expr_analyse_ct_offsetof(SemaContext *context, Expr *exp ArraySize index = 0; Type *result_type; if (!sema_expr_analyse_decl_element(context, - element, - type, - &member, - &index, - &result_type, - i, - i == 0 ? main_var->span : expr->span, - NULL)) return false; + element, + type, + &member, + &index, + &result_type, + i, + i == 0 ? main_var->span : expr->span, + NULL)) return false; if (member) { offset += member->offset; @@ -7539,7 +7539,7 @@ static inline bool sema_expr_analyse_compound_literal(SemaContext *context, Expr if (type_is_optional(type)) { SEMA_ERROR(expr->expr_compound_literal.type_info, - "The type here should always be written as a plain type and not an optional, please remove the '!'."); + "The type here should always be written as a plain type and not an optional, please remove the '!'."); return false; } if (!sema_expr_analyse_initializer_list(context, type, expr->expr_compound_literal.initializer)) return false; @@ -7679,8 +7679,8 @@ bool sema_analyse_cond_expr(SemaContext *context, Expr *expr) if (IS_OPTIONAL(expr)) { SEMA_ERROR(expr, "An optional %s cannot be implicitly converted to a regular boolean value, use '@ok()' " - "and '@catchof()' to conditionally execute on success or failure.", - type_quoted_error_string(expr->type)); + "and '@catchof()' to conditionally execute on success or failure.", + type_quoted_error_string(expr->type)); return false; } return cast_explicit(context, expr, type_bool); diff --git a/src/compiler/sema_initializers.c b/src/compiler/sema_initializers.c index 364bc4cbe..3c2d9f00e 100644 --- a/src/compiler/sema_initializers.c +++ b/src/compiler/sema_initializers.c @@ -6,10 +6,10 @@ static inline bool sema_expr_analyse_struct_plain_initializer(SemaContext *context, Decl *assigned, Expr *initializer); static inline bool sema_expr_analyse_array_plain_initializer(SemaContext *context, Type *assigned, Type *flattened, - Expr *initializer); + Expr *initializer); static inline bool sema_expr_analyse_untyped_initializer(SemaContext *context, Expr *initializer); static bool sema_expr_analyse_designated_initializer(SemaContext *context, Type *assigned, Type *flattened, - Expr *initializer); + Expr *initializer); static inline void sema_not_enough_elements_error(Expr *initializer, int element); static inline bool sema_expr_analyse_initializer(SemaContext *context, Type *assigned_type, Type *flattened, Expr *expr); static void sema_create_const_initializer_value(ConstInitializer *const_init, Expr *value); @@ -21,21 +21,21 @@ static Type *sema_find_type_of_element(SemaContext *context, Type *type, Designa MemberIndex sema_get_initializer_const_array_size(SemaContext *context, Expr *initializer, bool *may_be_array, bool *is_const_size); static MemberIndex sema_analyse_designator_index(SemaContext *context, Expr *index); static void sema_update_const_initializer_with_designator(ConstInitializer *const_init, - DesignatorElement **curr, - DesignatorElement **end, - Expr *value); + DesignatorElement **curr, + DesignatorElement **end, + Expr *value); static inline void sema_update_const_initializer_with_designator_struct(ConstInitializer *const_init, - DesignatorElement **curr, - DesignatorElement **end, - Expr *value); + DesignatorElement **curr, + DesignatorElement **end, + Expr *value); static inline void sema_update_const_initializer_with_designator_union(ConstInitializer *const_init, - DesignatorElement **curr, - DesignatorElement **end, - Expr *value); + DesignatorElement **curr, + DesignatorElement **end, + Expr *value); static inline void sema_update_const_initializer_with_designator_array(ConstInitializer *const_init, - DesignatorElement **curr, - DesignatorElement **end, - Expr *value); + DesignatorElement **curr, + DesignatorElement **end, + Expr *value); static inline void sema_update_const_initializer_with_designator( ConstInitializer *const_init, DesignatorElement **curr, @@ -222,7 +222,7 @@ static inline bool sema_expr_analyse_struct_plain_initializer(SemaContext *conte * @return true if analysis succeeds. */ static inline bool sema_expr_analyse_array_plain_initializer(SemaContext *context, Type *assigned, Type *flattened, - Expr *initializer) + Expr *initializer) { Expr **elements = initializer->initializer_list; bool inferred_len = type_len_is_inferred(flattened); @@ -396,7 +396,7 @@ static inline bool sema_expr_analyse_untyped_initializer(SemaContext *context, E } static bool sema_expr_analyse_designated_initializer(SemaContext *context, Type *assigned, Type *flattened, - Expr *initializer) + Expr *initializer) { Expr **init_expressions = initializer->designated_init_list; Type *original = flattened->canonical; @@ -491,11 +491,11 @@ static inline bool sema_expr_analyse_initializer(SemaContext *context, Type *ass // 5. If not, then we see if we have an array. if (flattened->type_kind == TYPE_UNTYPED_LIST || - flattened->type_kind == TYPE_ARRAY || - flattened->type_kind == TYPE_INFERRED_ARRAY || - flattened->type_kind == TYPE_INFERRED_VECTOR || - flattened->type_kind == TYPE_SUBARRAY || - flattened->type_kind == TYPE_VECTOR) + flattened->type_kind == TYPE_ARRAY || + flattened->type_kind == TYPE_INFERRED_ARRAY || + flattened->type_kind == TYPE_INFERRED_VECTOR || + flattened->type_kind == TYPE_SUBARRAY || + flattened->type_kind == TYPE_VECTOR) { return sema_expr_analyse_array_plain_initializer(context, assigned_type, flattened, expr); } @@ -654,9 +654,9 @@ static void sema_create_const_initializer_value(ConstInitializer *const_init, Ex * Update a struct element, e.g. { .a = 1 } or { .a[12] = { .b } } */ static inline void sema_update_const_initializer_with_designator_struct(ConstInitializer *const_init, - DesignatorElement **curr, - DesignatorElement **end, - Expr *value) + DesignatorElement **curr, + DesignatorElement **end, + Expr *value) { // Get the current path element that we're processing DesignatorElement *element = curr[0]; @@ -716,9 +716,9 @@ static inline void sema_update_const_initializer_with_designator_struct(ConstIni * we are allowed to completely overwrite the "memory" of .b */ static inline void sema_update_const_initializer_with_designator_union(ConstInitializer *const_init, - DesignatorElement **curr, - DesignatorElement **end, - Expr *value) + DesignatorElement **curr, + DesignatorElement **end, + Expr *value) { DesignatorElement *element = curr[0]; assert(element->kind == DESIGNATOR_FIELD); @@ -772,9 +772,9 @@ static inline void sema_update_const_initializer_with_designator_union(ConstInit * Update an array { [2] = 1 } */ static inline void sema_update_const_initializer_with_designator_array(ConstInitializer *const_init, - DesignatorElement **curr, - DesignatorElement **end, - Expr *value) + DesignatorElement **curr, + DesignatorElement **end, + Expr *value) { DesignatorElement *element = curr[0]; MemberIndex low_index = element->index; @@ -990,9 +990,9 @@ static Type *sema_find_type_of_element(SemaContext *context, Type *type, Designa return NULL; } Decl *member = sema_resolve_element_for_name(context, - type_flattened->decl->strukt.members, - elements_ref, - curr_index); + type_flattened->decl->strukt.members, + elements_ref, + curr_index); *member_ptr = member; if (!member) return NULL; return member->type; diff --git a/src/compiler/sema_name_resolution.c b/src/compiler/sema_name_resolution.c index 2732b47e6..528f72fb6 100644 --- a/src/compiler/sema_name_resolution.c +++ b/src/compiler/sema_name_resolution.c @@ -466,13 +466,13 @@ static void sema_report_error_on_decl(Decl *found, NameResolve *name_resolve) if (path_name) { sema_error_at(span, "The %s '%s::%s' is not visible from this module.", - private_name, path_name, - symbol); + private_name, path_name, + symbol); } else { sema_error_at(span, "The %s '%s' is not visible from this module.", - private_name, symbol); + private_name, symbol); } return; } @@ -489,7 +489,7 @@ static void sema_report_error_on_decl(Decl *found, NameResolve *name_resolve) else { sema_error_at(span, "Did you mean the %s '%s' in module %s? If so please add 'import %s'.", - maybe_name, symbol, module_name, module_name); + maybe_name, symbol, module_name, module_name); } return; } @@ -503,18 +503,18 @@ static void sema_report_error_on_decl(Decl *found, NameResolve *name_resolve) if (path_name) { sema_error_at(span, - "The %s '%s::%s' is defined in both '%s' and '%s', " + "The %s '%s::%s' is defined in both '%s' and '%s', " "please use either %s::%s or %s::%s to resolve the ambiguity.", - symbol_type, path_name, symbol, found_path, other_path, - found_path, symbol, other_path, symbol); + symbol_type, path_name, symbol, found_path, other_path, + found_path, symbol, other_path, symbol); } else { sema_error_at(span, - "The %s '%s' is defined in both '%s' and '%s', please use either " + "The %s '%s' is defined in both '%s' and '%s', please use either " "%s::%s or %s::%s to resolve the ambiguity.", - symbol_type, symbol, found_path, other_path, - found_path, symbol, other_path, symbol); + symbol_type, symbol, found_path, other_path, + found_path, symbol, other_path, symbol); } return; } @@ -718,10 +718,10 @@ Decl *sema_resolve_type_method(CompilationUnit *unit, Type *type, const char *me if (import->import.module->is_generic) continue; Decl *new_found = sema_resolve_method_in_module(import->import.module, type, method_name, - &private, &ambiguous, - import->import.import_private_as_public - ? METHOD_SEARCH_PRIVATE_IMPORTED - : METHOD_SEARCH_IMPORTED); + &private, &ambiguous, + import->import.import_private_as_public + ? METHOD_SEARCH_PRIVATE_IMPORTED + : METHOD_SEARCH_IMPORTED); if (!new_found) continue; if (found) { @@ -779,8 +779,8 @@ Decl *unit_resolve_parameterized_symbol(CompilationUnit *unit, NameResolve *name if (!decl) { decl = sema_find_decl_in_global_new(unit, &global_context.generic_symbols, - global_context.generic_module_list, - name_resolve, true); + global_context.generic_module_list, + name_resolve, true); } // 14. Error report if (!decl || name_resolve->ambiguous_other_decl) diff --git a/src/compiler/sema_stmts.c b/src/compiler/sema_stmts.c index e18064a47..f91a0cacf 100644 --- a/src/compiler/sema_stmts.c +++ b/src/compiler/sema_stmts.c @@ -726,7 +726,7 @@ static inline bool sema_analyse_catch_unwrap(SemaContext *context, Expr *expr) if (ident->type->canonical != type_anyfault) { SEMA_ERROR(ident, "Expected the variable to have the type %s, not %s.", type_quoted_error_string(type_anyfault), - type_quoted_error_string(ident->type)); + type_quoted_error_string(ident->type)); return false; } @@ -742,7 +742,7 @@ static inline bool sema_analyse_catch_unwrap(SemaContext *context, Expr *expr) if (type->type->canonical != type_anyfault) { SEMA_ERROR(type, "Expected the type to be %s, not %s.", type_quoted_error_string(type_anyfault), - type_quoted_error_string(type->type)); + type_quoted_error_string(type->type)); return false; } if (ident->expr_kind != EXPR_IDENTIFIER) @@ -1267,7 +1267,7 @@ static inline bool sema_analyse_foreach_stmt(SemaContext *context, Ast *statemen if (!may_be_array) { SEMA_ERROR(enumerator, - "This initializer appears to be a struct initializer when, an array initializer was expected."); + "This initializer appears to be a struct initializer when, an array initializer was expected."); return SCOPE_POP_ERROR(); } if (!is_const_size) @@ -1400,8 +1400,8 @@ static inline bool sema_analyse_foreach_stmt(SemaContext *context, Ast *statemen if (!type_is_integer(type_flatten(index_var_type))) { SEMA_ERROR(index->var.type_info, - "Index must be an integer type, '%s' is not valid.", - type_to_error_string(index_var_type)); + "Index must be an integer type, '%s' is not valid.", + type_to_error_string(index_var_type)); return false; } } @@ -1604,13 +1604,13 @@ static inline bool sema_analyse_if_stmt(SemaContext *context, Ast *statement) Ast *else_body = else_id ? astptr(else_id) : NULL; SCOPE_OUTER_START CondType cond_type = then->ast_kind == AST_IF_CATCH_SWITCH_STMT - ? COND_TYPE_UNWRAP : COND_TYPE_UNWRAP_BOOL; + ? COND_TYPE_UNWRAP : COND_TYPE_UNWRAP_BOOL; success = sema_analyse_cond(context, cond, cond_type); if (success && !ast_ok(then)) { SEMA_ERROR(then, - "The 'then' part of a single line if-statement must start on the same line as the 'if' or use '{ }'"); + "The 'then' part of a single line if-statement must start on the same line as the 'if' or use '{ }'"); success = false; } @@ -1623,10 +1623,10 @@ static inline bool sema_analyse_if_stmt(SemaContext *context, Ast *statement) success = false; } if (success && else_body->ast_kind != AST_COMPOUND_STMT && - else_body->ast_kind != AST_IF_STMT) + else_body->ast_kind != AST_IF_STMT) { SEMA_ERROR(else_body, - "An 'else' must use '{ }' even around a single statement."); + "An 'else' must use '{ }' even around a single statement."); success = false; } } @@ -2066,10 +2066,10 @@ static inline bool sema_check_value_case(SemaContext *context, Type *switch_type if (int_comp(const_expr->ixx, to_const_expr->ixx, BINARYOP_GT)) { sema_error_at(extend_span_with_token(expr->span, to_expr->span), - "The range is not valid because the first value (%s) is greater than the second (%s). " - "It would work if you swapped their order.", - int_to_str(const_expr->ixx, 10), - int_to_str(to_const_expr->ixx, 10)); + "The range is not valid because the first value (%s) is greater than the second (%s). " + "It would work if you swapped their order.", + int_to_str(const_expr->ixx, 10), + int_to_str(to_const_expr->ixx, 10)); return false; } Int128 range = int_sub(to_const_expr->ixx, const_expr->ixx).i; @@ -2217,9 +2217,9 @@ static bool sema_analyse_switch_body(SemaContext *context, Ast *statement, Sourc { Type *real_type = type_get_ptr(exprptr(stmt->case_stmt.expr)->const_expr.typeid); Decl *new_var = decl_new_var(any_switch->new_ident, any_switch->span, - type_info_new_base(any_switch->is_deref - ? real_type->pointer : real_type, any_switch->span), - VARDECL_LOCAL); + type_info_new_base(any_switch->is_deref + ? real_type->pointer : real_type, any_switch->span), + VARDECL_LOCAL); Expr *var_result = expr_variable(var_holder); if (!cast(var_result, real_type)) return false; if (any_switch->is_deref) @@ -2555,8 +2555,8 @@ static inline bool sema_analyse_switch_stmt(SemaContext *context, Ast *statement statement->switch_stmt.defer = context->active_scope.defer_last; if (!sema_analyse_switch_body(context, statement, cond ? cond->span : statement->span, - switch_type->canonical, - statement->switch_stmt.cases, any_decl ? &var_switch : NULL, any_decl)) + switch_type->canonical, + statement->switch_stmt.cases, any_decl ? &var_switch : NULL, any_decl)) { return SCOPE_POP_ERROR(); } @@ -2974,7 +2974,7 @@ bool sema_analyse_function_body(SemaContext *context, Decl *func) if (!any) { SEMA_ERROR(func, "To define a '@dynamic' method, the prototype method 'any.%s(...)' must exist. Did you spell the method name right?", - func->name); + func->name); return false; } @@ -2985,7 +2985,7 @@ bool sema_analyse_function_body(SemaContext *context, Decl *func) if (any_rtype->canonical != this_rtype->canonical) { SEMA_ERROR(type_infoptr(this_sig.rtype), "The prototype method has a return type %s, but this function returns %s, they need to match.", - type_quoted_error_string(any_rtype), type_quoted_error_string(this_rtype)); + type_quoted_error_string(any_rtype), type_quoted_error_string(this_rtype)); SEMA_NOTE(type_infoptr(any_sig.rtype), "The interface definition is here."); return false; } @@ -3014,7 +3014,7 @@ bool sema_analyse_function_body(SemaContext *context, Decl *func) if (param->type->canonical != any_params[i]->type->canonical) { SEMA_ERROR(param->var.type_info, "The prototype argument has type %s, but in this function it has type %s. Please make them match.", - type_quoted_error_string(any_params[i]->type), type_quoted_error_string(param->type)); + type_quoted_error_string(any_params[i]->type), type_quoted_error_string(param->type)); SEMA_NOTE(any_params[i]->var.type_info, "The interface definition is here."); return false; } diff --git a/src/compiler/sema_types.c b/src/compiler/sema_types.c index 406a3a722..922d40109 100644 --- a/src/compiler/sema_types.c +++ b/src/compiler/sema_types.c @@ -303,7 +303,7 @@ INLINE bool sema_resolve_vatype(SemaContext *context, TypeInfo *type_info) RETURN_SEMA_ERROR(type_info, "'%s' can only be used inside of a macro.", token_type_to_string(TOKEN_CT_VATYPE)); } ASSIGN_EXPR_OR_RET(Expr *arg_expr, sema_expr_analyse_ct_arg_index(context, type_info->unresolved_type_expr, NULL), - false); + false); if (arg_expr->expr_kind != EXPR_TYPEINFO) RETURN_SEMA_ERROR(arg_expr, "The argument was not a type."); assert(arg_expr->resolve_status == RESOLVE_DONE); @@ -337,8 +337,8 @@ static inline bool sema_resolve_type(SemaContext *context, TypeInfo *type_info, if (type_info->resolve_status == RESOLVE_RUNNING) { SEMA_ERROR(type_info, - "Circular dependency resolving type '%s'.", - type_info->unresolved.name); + "Circular dependency resolving type '%s'.", + type_info->unresolved.name); return type_info_poison(type_info); } @@ -380,7 +380,7 @@ static inline bool sema_resolve_type(SemaContext *context, TypeInfo *type_info, if (!allow_inferred_type) { SEMA_ERROR(type_info, "Inferred %s types can only be used in declarations with initializers and as macro parameters.", - type_info->kind == TYPE_INFO_INFERRED_VECTOR ? "vector" : "array"); + type_info->kind == TYPE_INFO_INFERRED_VECTOR ? "vector" : "array"); return type_info_poison(type_info); } FALLTHROUGH; diff --git a/src/compiler/semantic_analyser.c b/src/compiler/semantic_analyser.c index 4c5aa3e3c..a57b8c7da 100644 --- a/src/compiler/semantic_analyser.c +++ b/src/compiler/semantic_analyser.c @@ -171,6 +171,7 @@ static void register_generic_decls(CompilationUnit *unit, Decl **decls) VECEACH(decls, i) { Decl *decl = decls[i]; + if (decl->visibility == VISIBLE_LOCAL) continue; decl->unit = unit; switch (decl->decl_kind) { @@ -287,7 +288,7 @@ static void assign_panicfn(void) error_exit("'%s' is not a function function.", panicf); } if (!type_func_match(type_get_ptr(panicf_fn_type), type_void, 5, type_string, type_string, type_string, type_uint, - type_get_subarray(type_any))) + type_get_subarray(type_any))) { error_exit("Expected panic function to have the signature fn void(String, String, String, uint, ...)."); } diff --git a/src/compiler/target.c b/src/compiler/target.c index 7b35ec22a..52ae10b53 100644 --- a/src/compiler/target.c +++ b/src/compiler/target.c @@ -35,7 +35,7 @@ int target_alloca_addr_space() bool os_is_apple(OsType os_type) { return os_type == OS_TYPE_TVOS || os_type == OS_TYPE_WATCHOS || - os_type == OS_TYPE_MACOSX || os_type == OS_TYPE_IOS; + os_type == OS_TYPE_MACOSX || os_type == OS_TYPE_IOS; } bool arch_is_wasm(ArchType type) @@ -164,7 +164,7 @@ static inline void target_setup_arm_abi(void) if (platform_target.object_format == OBJ_FORMAT_MACHO) { if (platform_target.environment_type == ENV_TYPE_EABI - || platform_target.os == OS_TYPE_UNKNOWN /* or is M */) + || platform_target.os == OS_TYPE_UNKNOWN /* or is M */) { platform_target.arm.variant = ARM_AAPCS; return; @@ -221,10 +221,10 @@ static inline void target_setup_arm_abi(void) case ARM_AAPCS: case ARM_AAPCS_LINUX: if (platform_target.float_abi == FLOAT_ABI_HARD || - (platform_target.float_abi != FLOAT_ABI_SOFT && - (platform_target.environment_type == ENV_TYPE_GNUEABIHF || - platform_target.environment_type == ENV_TYPE_MUSLEABIHF || - platform_target.environment_type == ENV_TYPE_EABIHF))) + (platform_target.float_abi != FLOAT_ABI_SOFT && + (platform_target.environment_type == ENV_TYPE_GNUEABIHF || + platform_target.environment_type == ENV_TYPE_MUSLEABIHF || + platform_target.environment_type == ENV_TYPE_EABIHF))) { platform_target.arm.abi_variant = ARM_ABI_AAPCS_VFP; return; @@ -1704,8 +1704,8 @@ void *llvm_target_machine_create(void) DEBUG_LOG("Features: %s", platform_target.features); void *result = LLVMCreateTargetMachine(target, platform_target.target_triple, platform_target.cpu ? platform_target.cpu : "", platform_target.features ? platform_target.features : "", - (LLVMCodeGenOptLevel)platform_target.llvm_opt_level, - reloc_mode, LLVMCodeModelDefault); + (LLVMCodeGenOptLevel)platform_target.llvm_opt_level, + reloc_mode, LLVMCodeModelDefault); LLVMSetTargetMachineUseInitArray(result, true); if (!result) error_exit("Failed to create target machine."); LLVMSetTargetMachineAsmVerbosity(result, 1); @@ -1887,8 +1887,8 @@ void target_setup(BuildTarget *target) } platform_target.align_max_vector = os_arch_max_alignment_of_vector(platform_target.os, platform_target.arch, platform_target.environment_type, platform_target.arm.variant); platform_target.align_max_tls = os_arch_max_alignment_of_tls(platform_target.os, - platform_target.arch, - platform_target.environment_type); + platform_target.arch, + platform_target.environment_type); platform_target.reloc_model = arch_os_reloc_default(platform_target.arch, platform_target.os, platform_target.environment_type, diff --git a/src/compiler/types.c b/src/compiler/types.c index 411cc33a8..5eec71483 100644 --- a/src/compiler/types.c +++ b/src/compiler/types.c @@ -1108,7 +1108,7 @@ Type *type_get_vector(Type *vector_type, unsigned len) } static void type_create(const char *name, Type *location, TypeKind kind, unsigned bitsize, - unsigned align, unsigned pref_align) + unsigned align, unsigned pref_align) { assert(align); unsigned byte_size = (bitsize + 7) / 8; diff --git a/src/utils/errors.h b/src/utils/errors.h index 566464293..e7a073dff 100644 --- a/src/utils/errors.h +++ b/src/utils/errors.h @@ -10,8 +10,8 @@ #define INFO_LOG(_string, ...) \ do { \ - if (!debug_log) break; \ - printf("-- INFO: "); printf(_string, ##__VA_ARGS__); printf("\n"); \ + if (!debug_log) break; \ + printf("-- INFO: "); printf(_string, ##__VA_ARGS__); printf("\n"); \ } while (0) #ifdef NDEBUG #define REMINDER(_string, ...) do {} while (0) @@ -20,8 +20,8 @@ #define REMINDER(_string, ...) do { if (!debug_log) break; printf("TODO: %s -> in %s @ %s:%d\n", _string, __func__, __FILE__, __LINE__ , ##__VA_ARGS__); } while(0) #define DEBUG_LOG(_string, ...) \ do { \ - if (!debug_log) break; \ - printf("-- DEBUG: "); printf(_string, ##__VA_ARGS__); printf("\n"); \ + if (!debug_log) break; \ + printf("-- DEBUG: "); printf(_string, ##__VA_ARGS__); printf("\n"); \ } while (0) #endif @@ -58,7 +58,7 @@ #define EXPECT(_string, _value, _expected) \ do { long long __tempval1 = _value; long long __tempval2 = _expected; \ - TEST_ASSERT(__tempval1 == __tempval2, "Checking " _string ": expected %lld but was %lld.", __tempval2, __tempval1); } while(0) + TEST_ASSERT(__tempval1 == __tempval2, "Checking " _string ": expected %lld but was %lld.", __tempval2, __tempval1); } while(0) void evprintf(const char *format, va_list list); void eprintf(const char *format, ...); diff --git a/src/utils/find_msvc.c b/src/utils/find_msvc.c index 8f897022c..c8381cc38 100644 --- a/src/utils/find_msvc.c +++ b/src/utils/find_msvc.c @@ -39,36 +39,36 @@ WindowsSDK get_windows_link_paths() { int um_len = wcslen(paths.windows_sdk_um_library_path); WideCharToMultiByte( - CP_UTF8, // UTF-8 - 0, // config flags- I don't think we need these - paths.windows_sdk_um_library_path,// in - um_len, // in len - out.windows_sdk_um_library_path, // out - MAX_PATH, // out len - NULL, - NULL + CP_UTF8, // UTF-8 + 0, // config flags- I don't think we need these + paths.windows_sdk_um_library_path,// in + um_len, // in len + out.windows_sdk_um_library_path, // out + MAX_PATH, // out len + NULL, + NULL ); int ucrt_len = wcslen(paths.windows_sdk_ucrt_library_path); WideCharToMultiByte( - CP_UTF8, - 0, - paths.windows_sdk_ucrt_library_path, - ucrt_len, - out.windows_sdk_ucrt_library_path, - MAX_PATH, - NULL, - NULL + CP_UTF8, + 0, + paths.windows_sdk_ucrt_library_path, + ucrt_len, + out.windows_sdk_ucrt_library_path, + MAX_PATH, + NULL, + NULL ); int vsl_len = wcslen(paths.vs_library_path); WideCharToMultiByte( - CP_UTF8, - 0, - paths.vs_library_path, - vsl_len, - out.vs_library_path, - MAX_PATH, - NULL, - NULL + CP_UTF8, + 0, + paths.vs_library_path, + vsl_len, + out.vs_library_path, + MAX_PATH, + NULL, + NULL ); free_resources(&paths); @@ -117,8 +117,8 @@ DECLARE_INTERFACE_(ISetupInstance, IUnknown) { BEGIN_INTERFACE - // IUnknown methods - STDMETHOD(QueryInterface) (THIS_ REFIID, void**) PURE; + // IUnknown methods + STDMETHOD(QueryInterface) (THIS_ REFIID, void**) PURE; STDMETHOD_(ULONG, AddRef) (THIS) PURE; STDMETHOD_(ULONG, Release) (THIS) PURE; @@ -141,8 +141,8 @@ DECLARE_INTERFACE_(IEnumSetupInstances, IUnknown) { BEGIN_INTERFACE - // IUnknown methods - STDMETHOD(QueryInterface) (THIS_ REFIID, void**) PURE; + // IUnknown methods + STDMETHOD(QueryInterface) (THIS_ REFIID, void**) PURE; STDMETHOD_(ULONG, AddRef) (THIS) PURE; STDMETHOD_(ULONG, Release) (THIS) PURE; @@ -161,8 +161,8 @@ DECLARE_INTERFACE_(ISetupConfiguration, IUnknown) { BEGIN_INTERFACE - // IUnknown methods - STDMETHOD(QueryInterface) (THIS_ REFIID, void**) PURE; + // IUnknown methods + STDMETHOD(QueryInterface) (THIS_ REFIID, void**) PURE; STDMETHOD_(ULONG, AddRef) (THIS) PURE; STDMETHOD_(ULONG, Release) (THIS) PURE; @@ -237,14 +237,14 @@ bool visit_files_w(wchar_t* dir_name, Version_Data* data, Visit_Proc_W proc) { if (handle == INVALID_HANDLE_VALUE) return false; while (true) { - if ((find_data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) && (find_data.cFileName[0] != '.')) { - wchar_t* full_name = concat3(dir_name, L"\\", find_data.cFileName); - proc(find_data.cFileName, full_name, data); - free(full_name); - } + if ((find_data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) && (find_data.cFileName[0] != '.')) { + wchar_t* full_name = concat3(dir_name, L"\\", find_data.cFileName); + proc(find_data.cFileName, full_name, data); + free(full_name); + } - BOOL success = FindNextFileW(handle, &find_data); - if (!success) break; + BOOL success = FindNextFileW(handle, &find_data); + if (!success) break; } FindClose(handle); @@ -285,13 +285,13 @@ void win10_best(wchar_t* short_name, wchar_t* full_name, Version_Data* data) { if (i0 < data->best_version[0]) return; else if (i0 == data->best_version[0]) { - if (i1 < data->best_version[1]) return; - else if (i1 == data->best_version[1]) { - if (i2 < data->best_version[2]) return; - else if (i2 == data->best_version[2]) { - if (i3 < data->best_version[3]) return; - } - } + if (i1 < data->best_version[1]) return; + else if (i1 == data->best_version[1]) { + if (i2 < data->best_version[2]) return; + else if (i2 == data->best_version[2]) { + if (i3 < data->best_version[3]) return; + } + } } // we have to copy_string and free here because visit_files free's the full_name string @@ -300,10 +300,10 @@ void win10_best(wchar_t* short_name, wchar_t* full_name, Version_Data* data) { data->best_name = _wcsdup(full_name); if (data->best_name) { - data->best_version[0] = i0; - data->best_version[1] = i1; - data->best_version[2] = i2; - data->best_version[3] = i3; + data->best_version[0] = i0; + data->best_version[1] = i1; + data->best_version[2] = i2; + data->best_version[3] = i3; } } @@ -316,7 +316,7 @@ void win8_best(wchar_t* short_name, wchar_t* full_name, Version_Data* data) { if (i0 < data->best_version[0]) return; else if (i0 == data->best_version[0]) { - if (i1 < data->best_version[1]) return; + if (i1 < data->best_version[1]) return; } // we have to copy_string and free here because visit_files free's the full_name string @@ -325,8 +325,8 @@ void win8_best(wchar_t* short_name, wchar_t* full_name, Version_Data* data) { data->best_name = _wcsdup(full_name); if (data->best_name) { - data->best_version[0] = i0; - data->best_version[1] = i1; + data->best_version[0] = i0; + data->best_version[1] = i1; } } @@ -339,45 +339,45 @@ void find_windows_kit_root(Find_Result* result) { HKEY main_key; LSTATUS rc = RegOpenKeyExA(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows Kits\\Installed Roots", - 0, KEY_QUERY_VALUE | KEY_WOW64_32KEY | KEY_ENUMERATE_SUB_KEYS, &main_key); + 0, KEY_QUERY_VALUE | KEY_WOW64_32KEY | KEY_ENUMERATE_SUB_KEYS, &main_key); if (rc != S_OK) return; // Look for a Windows 10 entry. wchar_t* windows10_root = find_windows_kit_root_with_key(main_key, L"KitsRoot10"); if (windows10_root) { - wchar_t* windows10_lib = concat2(windows10_root, L"Lib"); - free(windows10_root); + wchar_t* windows10_lib = concat2(windows10_root, L"Lib"); + free(windows10_root); - Version_Data data = { 0 }; - visit_files_w(windows10_lib, &data, win10_best); - free(windows10_lib); + Version_Data data = { 0 }; + visit_files_w(windows10_lib, &data, win10_best); + free(windows10_lib); - if (data.best_name) { - result->windows_sdk_version = 10; - result->windows_sdk_root = data.best_name; - RegCloseKey(main_key); - return; - } + if (data.best_name) { + result->windows_sdk_version = 10; + result->windows_sdk_root = data.best_name; + RegCloseKey(main_key); + return; + } } // Look for a Windows 8 entry. wchar_t* windows8_root = find_windows_kit_root_with_key(main_key, L"KitsRoot81"); if (windows8_root) { - wchar_t* windows8_lib = concat2(windows8_root, L"Lib"); - free(windows8_root); + wchar_t* windows8_lib = concat2(windows8_root, L"Lib"); + free(windows8_root); - Version_Data data = { 0 }; - visit_files_w(windows8_lib, &data, win8_best); - free(windows8_lib); + Version_Data data = { 0 }; + visit_files_w(windows8_lib, &data, win8_best); + free(windows8_lib); - if (data.best_name) { - result->windows_sdk_version = 8; - result->windows_sdk_root = data.best_name; - RegCloseKey(main_key); - return; - } + if (data.best_name) { + result->windows_sdk_version = 8; + result->windows_sdk_root = data.best_name; + RegCloseKey(main_key); + return; + } } // If we get here, we failed to find anything. @@ -411,66 +411,66 @@ bool find_visual_studio_2017_by_fighting_through_microsoft_craziness(Find_Result bool found_visual_studio_2017 = false; while (1) { - ULONG found = 0; - ISetupInstance* instance = NULL; - HRESULT hr = CALL_STDMETHOD(instances, Next, 1, &instance, &found); - if (hr != S_OK) break; + ULONG found = 0; + ISetupInstance* instance = NULL; + HRESULT hr = CALL_STDMETHOD(instances, Next, 1, &instance, &found); + if (hr != S_OK) break; - BSTR bstr_inst_path; - hr = CALL_STDMETHOD(instance, GetInstallationPath, &bstr_inst_path); - CALL_STDMETHOD_(instance, Release); - if (hr != S_OK) continue; + BSTR bstr_inst_path; + hr = CALL_STDMETHOD(instance, GetInstallationPath, &bstr_inst_path); + CALL_STDMETHOD_(instance, Release); + if (hr != S_OK) continue; - wchar_t* tools_filename = concat2(bstr_inst_path, L"\\VC\\Auxiliary\\Build\\Microsoft.VCToolsVersion.default.txt"); - SysFreeString(bstr_inst_path); + wchar_t* tools_filename = concat2(bstr_inst_path, L"\\VC\\Auxiliary\\Build\\Microsoft.VCToolsVersion.default.txt"); + SysFreeString(bstr_inst_path); - FILE* f; - errno_t open_result = _wfopen_s(&f, tools_filename, L"rt"); - free(tools_filename); - if (open_result != 0) continue; - if (!f) continue; + FILE* f; + errno_t open_result = _wfopen_s(&f, tools_filename, L"rt"); + free(tools_filename); + if (open_result != 0) continue; + if (!f) continue; - LARGE_INTEGER tools_file_size; - HANDLE file_handle = (HANDLE)_get_osfhandle(_fileno(f)); - BOOL success = GetFileSizeEx(file_handle, &tools_file_size); - if (!success) { - fclose(f); - continue; - } + LARGE_INTEGER tools_file_size; + HANDLE file_handle = (HANDLE)_get_osfhandle(_fileno(f)); + BOOL success = GetFileSizeEx(file_handle, &tools_file_size); + if (!success) { + fclose(f); + continue; + } - size_t version_length = (size_t)(tools_file_size.QuadPart + 1); // Warning: This multiplication by 2 presumes there is no variable-length encoding in the wchars (wacky characters in the file could betray this expectation). - wchar_t* version = (wchar_t*)cmalloc(version_length * 2); + size_t version_length = (size_t)(tools_file_size.QuadPart + 1); // Warning: This multiplication by 2 presumes there is no variable-length encoding in the wchars (wacky characters in the file could betray this expectation). + wchar_t* version = (wchar_t*)cmalloc(version_length * 2); - wchar_t* read_result = fgetws(version, version_length, f); - fclose(f); - if (!read_result) continue; + wchar_t* read_result = fgetws(version, version_length, f); + fclose(f); + if (!read_result) continue; - wchar_t* version_tail = wcschr(version, '\n'); - if (version_tail) *version_tail = 0; // Stomp the data, because nobody cares about it. + wchar_t* version_tail = wcschr(version, '\n'); + if (version_tail) *version_tail = 0; // Stomp the data, because nobody cares about it. - wchar_t* library_path = concat4(bstr_inst_path, L"\\VC\\Tools\\MSVC\\", version, L"\\lib\\x64"); - wchar_t* library_file = concat2(library_path, L"\\vcruntime.lib"); // @Speed: Could have library_path point to this string, with a smaller count, to save on memory flailing! + wchar_t* library_path = concat4(bstr_inst_path, L"\\VC\\Tools\\MSVC\\", version, L"\\lib\\x64"); + wchar_t* library_file = concat2(library_path, L"\\vcruntime.lib"); // @Speed: Could have library_path point to this string, with a smaller count, to save on memory flailing! - if (os_file_exists(library_file)) { - wchar_t* link_exe_path = concat4(bstr_inst_path, L"\\VC\\Tools\\MSVC\\", version, L"\\bin\\Hostx64\\x64"); - free(version); + if (os_file_exists(library_file)) { + wchar_t* link_exe_path = concat4(bstr_inst_path, L"\\VC\\Tools\\MSVC\\", version, L"\\bin\\Hostx64\\x64"); + free(version); - result->vs_exe_path = link_exe_path; - result->vs_library_path = library_path; - result->is_vs_2017 = true; - found_visual_studio_2017 = true; - break; - } + result->vs_exe_path = link_exe_path; + result->vs_library_path = library_path; + result->is_vs_2017 = true; + found_visual_studio_2017 = true; + break; + } - free(version); + free(version); - /* - Ryan Saunderson said: - "Clang uses the 'SetupInstance->GetInstallationVersion' / ISetupHelper->ParseVersion to find the newest version - and then reads the tools file to define the tools path - which is definitely better than what i did." + /* + Ryan Saunderson said: + "Clang uses the 'SetupInstance->GetInstallationVersion' / ISetupHelper->ParseVersion to find the newest version + and then reads the tools file to define the tools path - which is definitely better than what i did." - So... @Incomplete: Should probably pick the newest version... - */ + So... @Incomplete: Should probably pick the newest version... + */ } CALL_STDMETHOD_(instances, Release); @@ -508,42 +508,42 @@ void find_visual_studio_by_fighting_through_microsoft_craziness(Find_Result* res const int NUM_VERSIONS = sizeof(versions) / sizeof(versions[0]); for (int i = 0; i < NUM_VERSIONS; i++) { - wchar_t* v = versions[i]; + wchar_t* v = versions[i]; - DWORD dw_type; - DWORD cb_data; + DWORD dw_type; + DWORD cb_data; - LSTATUS rc = RegQueryValueExW(vs7_key, v, NULL, &dw_type, NULL, &cb_data); - if ((rc == ERROR_FILE_NOT_FOUND) || (dw_type != REG_SZ)) { - continue; - } + LSTATUS rc = RegQueryValueExW(vs7_key, v, NULL, &dw_type, NULL, &cb_data); + if ((rc == ERROR_FILE_NOT_FOUND) || (dw_type != REG_SZ)) { + continue; + } - wchar_t* buffer = (wchar_t*)cmalloc(cb_data); - if (!buffer) return; + wchar_t* buffer = (wchar_t*)cmalloc(cb_data); + if (!buffer) return; - rc = RegQueryValueExW(vs7_key, v, NULL, NULL, (LPBYTE)buffer, &cb_data); - if (rc != 0) continue; + rc = RegQueryValueExW(vs7_key, v, NULL, NULL, (LPBYTE)buffer, &cb_data); + if (rc != 0) continue; - // @Robustness: Do the zero-termination thing suggested in the RegQueryValue docs? + // @Robustness: Do the zero-termination thing suggested in the RegQueryValue docs? - wchar_t* lib_path = concat2(buffer, L"VC\\Lib\\amd64"); + wchar_t* lib_path = concat2(buffer, L"VC\\Lib\\amd64"); - // Check to see whether a vcruntime.lib actually exists here. - wchar_t* vcruntime_filename = concat2(lib_path, L"\\vcruntime.lib"); - bool vcruntime_exists = os_file_exists(vcruntime_filename); - free(vcruntime_filename); + // Check to see whether a vcruntime.lib actually exists here. + wchar_t* vcruntime_filename = concat2(lib_path, L"\\vcruntime.lib"); + bool vcruntime_exists = os_file_exists(vcruntime_filename); + free(vcruntime_filename); - if (vcruntime_exists) { - result->vs_exe_path = concat2(buffer, L"VC\\bin\\amd64"); - result->vs_library_path = lib_path; + if (vcruntime_exists) { + result->vs_exe_path = concat2(buffer, L"VC\\bin\\amd64"); + result->vs_library_path = lib_path; - free(buffer); - RegCloseKey(vs7_key); - return; - } + free(buffer); + RegCloseKey(vs7_key); + return; + } - free(lib_path); - free(buffer); + free(lib_path); + free(buffer); } RegCloseKey(vs7_key); @@ -557,8 +557,8 @@ Find_Result find_visual_studio_and_windows_sdk() { find_windows_kit_root(&result); if (result.windows_sdk_root) { - result.windows_sdk_um_library_path = concat2(result.windows_sdk_root, L"\\um\\x64"); - result.windows_sdk_ucrt_library_path = concat2(result.windows_sdk_root, L"\\ucrt\\x64"); + result.windows_sdk_um_library_path = concat2(result.windows_sdk_root, L"\\um\\x64"); + result.windows_sdk_ucrt_library_path = concat2(result.windows_sdk_root, L"\\ucrt\\x64"); } find_visual_studio_by_fighting_through_microsoft_craziness(&result); diff --git a/src/utils/http.c b/src/utils/http.c index 12195a2ab..9910923c0 100644 --- a/src/utils/http.c +++ b/src/utils/http.c @@ -32,7 +32,7 @@ const char *download_file(const char *url, const char *resource, const char *fil // Use WinHttpOpen to obtain a session handle. HINTERNET session = WinHttpOpen(L"C3C/1.0", WINHTTP_ACCESS_TYPE_DEFAULT_PROXY, - WINHTTP_NO_PROXY_NAME, WINHTTP_NO_PROXY_BYPASS, 0); + WINHTTP_NO_PROXY_NAME, WINHTTP_NO_PROXY_BYPASS, 0); if (!session) error_exit("Failed to create http session."); // Specify an HTTP server. diff --git a/src/utils/lib.h b/src/utils/lib.h index 9be7cd750..5c95882df 100644 --- a/src/utils/lib.h +++ b/src/utils/lib.h @@ -293,12 +293,12 @@ static inline void* expand_(void *vec, size_t element_size) for (unsigned (_index) = 0, CONCAT(__vecsize_, __LINE__) = vec_size(_vec); (_index) < CONCAT(__vecsize_, __LINE__); (_index)++) #define foreach(type__, vec__) \ type__* foreach_vec__ = vec__; unsigned foreach_len__ = vec_size(foreach_vec__); \ - type__ val; if (foreach_vec__) val = foreach_vec__[0]; \ + type__ val; if (foreach_vec__) val = foreach_vec__[0]; \ for (unsigned foreach_index = 0; foreach_index < foreach_len__; val = foreach_vec__[++foreach_index]) #define FOREACH_BEGIN_IDX(idx__, decl__, vec__) \ void* CONCAT(foreach_vec_, __LINE__) = (vec__); unsigned CONCAT(foreach_len_, __LINE__) = vec_size(CONCAT(foreach_vec_, __LINE__)); \ - for (unsigned idx__ = 0; idx__ < CONCAT(foreach_len_, __LINE__); idx__++) { decl__ = ((void**)CONCAT(foreach_vec_, __LINE__))[idx__]; + for (unsigned idx__ = 0; idx__ < CONCAT(foreach_len_, __LINE__); idx__++) { decl__ = ((void**)CONCAT(foreach_vec_, __LINE__))[idx__]; #define FOREACH_END() } do {} while (0) #define FOREACH_BEGIN(decl__, vec__) FOREACH_BEGIN_IDX(CONCAT(idx__, __LINE__), decl__, vec__) @@ -523,9 +523,9 @@ static inline signed char char_is_valid_escape(char c) static inline bool char_is_base64(char c) { return (c >= 'A' && c <= 'Z') - || (c >= 'a' && c <= 'z') - || (c >= '0' && c <= '9') - || c == '+' || c == '/'; + || (c >= 'a' && c <= 'z') + || (c >= '0' && c <= '9') + || c == '+' || c == '/'; } static inline bool char_is_hex(char c) diff --git a/src/utils/unzipper.c b/src/utils/unzipper.c index 4e47d2a9e..5f6b62f93 100644 --- a/src/utils/unzipper.c +++ b/src/utils/unzipper.c @@ -13,52 +13,52 @@ uint8_t file_out_buffer[FILE_OUTBUF_LEN]; typedef PACK(struct { - uint32_t signature; // 0x04034B50 - uint16_t version_needed_to_extract; // unsupported - uint16_t general_purpose_bit_flag; // unsupported - uint16_t compression_method; - uint16_t last_mod_file_time; - uint16_t last_mod_file_date; - uint32_t crc32; - uint32_t compressed_size; - uint32_t uncompressed_size; - uint16_t filename_len; - uint16_t extra_field_len; // unsupported + uint32_t signature; // 0x04034B50 + uint16_t version_needed_to_extract; // unsupported + uint16_t general_purpose_bit_flag; // unsupported + uint16_t compression_method; + uint16_t last_mod_file_time; + uint16_t last_mod_file_date; + uint32_t crc32; + uint32_t compressed_size; + uint32_t uncompressed_size; + uint16_t filename_len; + uint16_t extra_field_len; // unsupported }) JZLocalFileHeader; typedef PACK(struct { - uint32_t signature; // 0x02014B50 - uint16_t version_made_by; // unsupported - uint16_t version_needed_to_extract; // unsupported - uint16_t general_purpose_bit_flag; // unsupported - uint16_t compression_method; - uint16_t last_mod_file_time; - uint16_t last_mod_file_date; - uint32_t crc32; - uint32_t compressed_size; - uint32_t uncompressed_size; - uint16_t file_name_len; - uint16_t extra_field_len; // unsupported - uint16_t comment_len; // unsupported - uint16_t disk_number_start; // unsupported - uint16_t internal_file_attributes; // unsupported - uint32_t external_file_attributes; // unsupported - uint32_t relative_offset_of_local_header; + uint32_t signature; // 0x02014B50 + uint16_t version_made_by; // unsupported + uint16_t version_needed_to_extract; // unsupported + uint16_t general_purpose_bit_flag; // unsupported + uint16_t compression_method; + uint16_t last_mod_file_time; + uint16_t last_mod_file_date; + uint32_t crc32; + uint32_t compressed_size; + uint32_t uncompressed_size; + uint16_t file_name_len; + uint16_t extra_field_len; // unsupported + uint16_t comment_len; // unsupported + uint16_t disk_number_start; // unsupported + uint16_t internal_file_attributes; // unsupported + uint32_t external_file_attributes; // unsupported + uint32_t relative_offset_of_local_header; }) ZipGlobalFileHeader; typedef PACK(struct { - uint32_t signature; // 0x06054b50 - uint16_t disk_number; // unsupported - uint16_t central_dir_disk_number; // unsupported - uint16_t num_entries_this_disk; // unsupported - uint16_t num_entries; - uint32_t central_dir_size; - uint32_t central_dir_offset; - uint16_t zip_comment_len; - // Followed by .ZIP file comment (variable size) + uint32_t signature; // 0x06054b50 + uint16_t disk_number; // unsupported + uint16_t central_dir_disk_number; // unsupported + uint16_t num_entries_this_disk; // unsupported + uint16_t num_entries; + uint32_t central_dir_size; + uint32_t central_dir_offset; + uint16_t zip_comment_len; + // Followed by .ZIP file comment (variable size) }) ZipEndRecord; INLINE bool read_all(FILE *file, void *buffer, size_t len) @@ -144,7 +144,7 @@ const char *zip_dir_iterator_next(ZipDirIterator *iterator, ZipFile *file) return str_printf("Illegal compression method '%s'", file->name); } if (file_header.compression_method == 0 && - (file_header.compressed_size != file_header.uncompressed_size)) + (file_header.compressed_size != file_header.uncompressed_size)) { return str_printf("Invalid compression '%s'", file->name); } diff --git a/src/utils/whereami.c b/src/utils/whereami.c index 3964d80aa..28700d7e4 100644 --- a/src/utils/whereami.c +++ b/src/utils/whereami.c @@ -340,7 +340,7 @@ static int get_executable_path_raw(char *out, int capacity, int *dirname_length) } #elif defined(__DragonFly__) || defined(__FreeBSD__) || \ - defined(__FreeBSD_kernel__) || defined(__NetBSD__) + defined(__FreeBSD_kernel__) || defined(__NetBSD__) #include #include diff --git a/src/version.h b/src/version.h index 684f83277..9878e5e13 100644 --- a/src/version.h +++ b/src/version.h @@ -1 +1 @@ -#define COMPILER_VERSION "0.4.569" \ No newline at end of file +#define COMPILER_VERSION "0.4.570" \ No newline at end of file diff --git a/test/test_suite/generic/generic_local.c3 b/test/test_suite/generic/generic_local.c3 new file mode 100644 index 000000000..de8a42b88 --- /dev/null +++ b/test/test_suite/generic/generic_local.c3 @@ -0,0 +1,23 @@ +module testing; +import std::io; +import foo; + +def Foo = foo::Foo; + +fn void main() +{ + Foo f; +} + +module foo; +import foo::private; + +// Bug #856 +def Foo = distinct inline PrivateFoo(); // #error: could not be found + +module foo::private() @local; + +struct PrivateFoo +{ + Type x; +} \ No newline at end of file