authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2016-12-05 21:39:15-05:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2016-12-05 21:39:15-05:00
log0c531d447df88ed6c46e759fbfc9d253d2650c22
treef2c83b6c7c099e155f3b1ff58186f907e5494126
parentbed83bc5a14aa6c0480dcfa842d97cce64427e1b

remove the boolean argument from setFnTest


5 files changed, 11 insertions(+), 29 deletions(-)

doc/langref.md+4
......@@ -616,3 +616,7 @@ or `switch` with compile time constants, and inline functions.
616616### @intType(inline is_signed: bool, inline bit_count: u8) -> type
617617
618618This function returns an integer type with the given signness and bit count.
619
620### @setFnTest(func)
621
622Makes the target function a test function.
src/all_types.hpp-2
......@@ -987,7 +987,6 @@ struct FnTableEntry {
987987
988988 AstNode *fn_no_inline_set_node;
989989 AstNode *fn_export_set_node;
990 AstNode *fn_test_set_node;
991990 AstNode *fn_static_eval_set_node;
992991
993992 ZigList<IrInstruction *> alloca_list;
......@@ -1674,7 +1673,6 @@ struct IrInstructionSetFnTest {
16741673 IrInstruction base;
16751674
16761675 IrInstruction *fn_value;
1677 IrInstruction *is_test;
16781676};
16791677
16801678struct IrInstructionSetFnVisible {
src/codegen.cpp+1-1
......@@ -3083,7 +3083,7 @@ static void define_builtin_fns(CodeGen *g) {
30833083 create_builtin_fn_with_arg_count(g, BuiltinFnIdCompileErr, "compileError", 1);
30843084 create_builtin_fn_with_arg_count(g, BuiltinFnIdIntType, "intType", 2);
30853085 create_builtin_fn_with_arg_count(g, BuiltinFnIdUnreachable, "unreachable", 0);
3086 create_builtin_fn_with_arg_count(g, BuiltinFnIdSetFnTest, "setFnTest", 2);
3086 create_builtin_fn_with_arg_count(g, BuiltinFnIdSetFnTest, "setFnTest", 1);
30873087 create_builtin_fn_with_arg_count(g, BuiltinFnIdSetFnVisible, "setFnVisible", 2);
30883088 create_builtin_fn_with_arg_count(g, BuiltinFnIdSetFnNoInline, "setFnNoInline", 2);
30893089 create_builtin_fn_with_arg_count(g, BuiltinFnIdSetDebugSafety, "setDebugSafety", 2);
src/ir.cpp+6-24
......@@ -934,15 +934,13 @@ static IrInstruction *ir_build_ptr_type_child(IrBuilder *irb, Scope *scope, AstN
934934 return &instruction->base;
935935}
936936
937static IrInstruction *ir_build_set_fn_test(IrBuilder *irb, Scope *scope, AstNode *source_node, IrInstruction *fn_value,
938 IrInstruction *is_test)
937static IrInstruction *ir_build_set_fn_test(IrBuilder *irb, Scope *scope, AstNode *source_node,
938 IrInstruction *fn_value)
939939{
940940 IrInstructionSetFnTest *instruction = ir_build_instruction<IrInstructionSetFnTest>(irb, scope, source_node);
941941 instruction->fn_value = fn_value;
942 instruction->is_test = is_test;
943942
944943 ir_ref_instruction(fn_value);
945 ir_ref_instruction(is_test);
946944
947945 return &instruction->base;
948946}
......@@ -1786,12 +1784,7 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo
17861784 if (arg0_value == irb->codegen->invalid_instruction)
17871785 return arg0_value;
17881786
1789 AstNode *arg1_node = node->data.fn_call_expr.params.at(1);
1790 IrInstruction *arg1_value = ir_gen_node(irb, arg1_node, scope);
1791 if (arg1_value == irb->codegen->invalid_instruction)
1792 return arg1_value;
1793
1794 return ir_build_set_fn_test(irb, scope, node, arg0_value, arg1_value);
1787 return ir_build_set_fn_test(irb, scope, node, arg0_value);
17951788 }
17961789 case BuiltinFnIdSetFnVisible:
17971790 {
......@@ -5680,26 +5673,15 @@ static TypeTableEntry *ir_analyze_instruction_set_fn_test(IrAnalyze *ira,
56805673 IrInstructionSetFnTest *set_fn_test_instruction)
56815674{
56825675 IrInstruction *fn_value = set_fn_test_instruction->fn_value->other;
5683 IrInstruction *is_test_value = set_fn_test_instruction->is_test->other;
56845676
56855677 FnTableEntry *fn_entry = ir_resolve_fn(ira, fn_value);
56865678 if (!fn_entry)
56875679 return ira->codegen->builtin_types.entry_invalid;
56885680
5689 if (!ir_resolve_bool(ira, is_test_value, &fn_entry->is_test))
5690 return ira->codegen->builtin_types.entry_invalid;
5691
5692 AstNode *source_node = set_fn_test_instruction->base.source_node;
5693 if (fn_entry->fn_test_set_node) {
5694 ErrorMsg *msg = add_node_error(ira->codegen, source_node,
5695 buf_sprintf("function test attribute set twice"));
5696 add_error_note(ira->codegen, msg, fn_entry->fn_test_set_node, buf_sprintf("first set here"));
5697 return ira->codegen->builtin_types.entry_invalid;
5698 }
5699 fn_entry->fn_test_set_node = source_node;
5700
5701 if (fn_entry->is_test)
5681 if (!fn_entry->is_test) {
5682 fn_entry->is_test = true;
57025683 ira->codegen->test_fn_count += 1;
5684 }
57035685
57045686 ir_build_const_from(ira, &set_fn_test_instruction->base, false);
57055687 return ira->codegen->builtin_types.entry_void;
src/ir_print.cpp-2
......@@ -491,8 +491,6 @@ static void ir_print_enum_field_ptr(IrPrint *irp, IrInstructionEnumFieldPtr *ins
491491static void ir_print_set_fn_test(IrPrint *irp, IrInstructionSetFnTest *instruction) {
492492 fprintf(irp->f, "@setFnTest(");
493493 ir_print_other_instruction(irp, instruction->fn_value);
494 fprintf(irp->f, ", ");
495 ir_print_other_instruction(irp, instruction->is_test);
496494 fprintf(irp->f, ")");
497495}
498496