mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-07 08:08:50 +00:00
Make -verbose-errors the default; -terse-errors to disable it
This commit is contained in:
@@ -288,7 +288,7 @@ struct BuildContext {
|
|||||||
|
|
||||||
bool ignore_warnings;
|
bool ignore_warnings;
|
||||||
bool warnings_as_errors;
|
bool warnings_as_errors;
|
||||||
bool show_error_line;
|
bool hide_error_line;
|
||||||
|
|
||||||
bool ignore_lazy;
|
bool ignore_lazy;
|
||||||
bool ignore_llvm_build;
|
bool ignore_llvm_build;
|
||||||
@@ -1033,7 +1033,7 @@ gb_internal String get_fullpath_core(gbAllocator a, String path) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
gb_internal bool show_error_line(void) {
|
gb_internal bool show_error_line(void) {
|
||||||
return build_context.show_error_line;
|
return !build_context.hide_error_line;
|
||||||
}
|
}
|
||||||
|
|
||||||
gb_internal bool has_asm_extension(String const &path) {
|
gb_internal bool has_asm_extension(String const &path) {
|
||||||
|
|||||||
+5
-1
@@ -1679,9 +1679,13 @@ gb_internal bool check_unary_op(CheckerContext *c, Operand *o, Token op) {
|
|||||||
|
|
||||||
case Token_Not:
|
case Token_Not:
|
||||||
if (!is_type_boolean(type)) {
|
if (!is_type_boolean(type)) {
|
||||||
|
ERROR_BLOCK();
|
||||||
str = expr_to_string(o->expr);
|
str = expr_to_string(o->expr);
|
||||||
error(op, "Operator '%.*s' is only allowed on boolean expression", LIT(op.string));
|
error(op, "Operator '%.*s' is only allowed on boolean expressions", LIT(op.string));
|
||||||
gb_string_free(str);
|
gb_string_free(str);
|
||||||
|
if (is_type_integer(type)) {
|
||||||
|
error_line("\tSuggestion: Did you mean to use the bitwise not operator '~'?\n");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|||||||
+24
-5
@@ -121,7 +121,26 @@ gb_internal void end_error_block(void) {
|
|||||||
isize n = global_error_collector.error_buffer.count;
|
isize n = global_error_collector.error_buffer.count;
|
||||||
if (n > 0) {
|
if (n > 0) {
|
||||||
u8 *text = global_error_collector.error_buffer.data;
|
u8 *text = global_error_collector.error_buffer.data;
|
||||||
if (show_error_line() && n >= 2 && !(text[n-2] == '\n' && text[n-1] == '\n')) {
|
|
||||||
|
bool add_extra_newline = false;
|
||||||
|
|
||||||
|
if (show_error_line()) {
|
||||||
|
if (n >= 2 && !(text[n-2] == '\n' && text[n-1] == '\n')) {
|
||||||
|
add_extra_newline = true;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
isize newline_count = 0;
|
||||||
|
for (isize i = 0; i < n; i++) {
|
||||||
|
if (text[i] == '\n') {
|
||||||
|
newline_count += 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (newline_count > 1) {
|
||||||
|
add_extra_newline = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (add_extra_newline) {
|
||||||
// add an extra new line as padding when the error line is being shown
|
// add an extra new line as padding when the error line is being shown
|
||||||
error_line("\n");
|
error_line("\n");
|
||||||
}
|
}
|
||||||
@@ -198,12 +217,12 @@ gb_internal bool show_error_on_line(TokenPos const &pos, TokenPos end) {
|
|||||||
// TODO(bill): This assumes ASCII
|
// TODO(bill): This assumes ASCII
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
MAX_LINE_LENGTH = 76,
|
MAX_LINE_LENGTH = 80,
|
||||||
MAX_TAB_WIDTH = 8,
|
MAX_TAB_WIDTH = 8,
|
||||||
ELLIPSIS_PADDING = 8
|
ELLIPSIS_PADDING = 8 // `... ...`
|
||||||
};
|
};
|
||||||
|
|
||||||
error_out("\n\t");
|
error_out("\t");
|
||||||
if (line.len+MAX_TAB_WIDTH+ELLIPSIS_PADDING > MAX_LINE_LENGTH) {
|
if (line.len+MAX_TAB_WIDTH+ELLIPSIS_PADDING > MAX_LINE_LENGTH) {
|
||||||
i32 const half_width = MAX_LINE_LENGTH/2;
|
i32 const half_width = MAX_LINE_LENGTH/2;
|
||||||
i32 left = cast(i32)(offset);
|
i32 left = cast(i32)(offset);
|
||||||
@@ -244,7 +263,7 @@ gb_internal bool show_error_on_line(TokenPos const &pos, TokenPos end) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
error_out("\n\n");
|
error_out("\n");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
+1
-3
@@ -578,9 +578,7 @@ gb_internal ExactValue exact_unary_operator_value(TokenKind op, ExactValue v, i3
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
failure:
|
failure:;
|
||||||
GB_PANIC("Invalid unary operation, %.*s", LIT(token_strings[op]));
|
|
||||||
|
|
||||||
ExactValue error_value = {};
|
ExactValue error_value = {};
|
||||||
return error_value;
|
return error_value;
|
||||||
}
|
}
|
||||||
|
|||||||
+8
-1
@@ -659,6 +659,7 @@ enum BuildFlagKind {
|
|||||||
|
|
||||||
BuildFlag_IgnoreWarnings,
|
BuildFlag_IgnoreWarnings,
|
||||||
BuildFlag_WarningsAsErrors,
|
BuildFlag_WarningsAsErrors,
|
||||||
|
BuildFlag_TerseErrors,
|
||||||
BuildFlag_VerboseErrors,
|
BuildFlag_VerboseErrors,
|
||||||
BuildFlag_ErrorPosStyle,
|
BuildFlag_ErrorPosStyle,
|
||||||
|
|
||||||
@@ -832,6 +833,7 @@ gb_internal bool parse_build_flags(Array<String> args) {
|
|||||||
|
|
||||||
add_flag(&build_flags, BuildFlag_IgnoreWarnings, str_lit("ignore-warnings"), BuildFlagParam_None, Command_all);
|
add_flag(&build_flags, BuildFlag_IgnoreWarnings, str_lit("ignore-warnings"), BuildFlagParam_None, Command_all);
|
||||||
add_flag(&build_flags, BuildFlag_WarningsAsErrors, str_lit("warnings-as-errors"), BuildFlagParam_None, Command_all);
|
add_flag(&build_flags, BuildFlag_WarningsAsErrors, str_lit("warnings-as-errors"), BuildFlagParam_None, Command_all);
|
||||||
|
add_flag(&build_flags, BuildFlag_TerseErrors, str_lit("terse-errors"), BuildFlagParam_None, Command_all);
|
||||||
add_flag(&build_flags, BuildFlag_VerboseErrors, str_lit("verbose-errors"), BuildFlagParam_None, Command_all);
|
add_flag(&build_flags, BuildFlag_VerboseErrors, str_lit("verbose-errors"), BuildFlagParam_None, Command_all);
|
||||||
add_flag(&build_flags, BuildFlag_ErrorPosStyle, str_lit("error-pos-style"), BuildFlagParam_String, Command_all);
|
add_flag(&build_flags, BuildFlag_ErrorPosStyle, str_lit("error-pos-style"), BuildFlagParam_String, Command_all);
|
||||||
|
|
||||||
@@ -1462,8 +1464,13 @@ gb_internal bool parse_build_flags(Array<String> args) {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case BuildFlag_TerseErrors:
|
||||||
|
build_context.hide_error_line = true;
|
||||||
|
break;
|
||||||
case BuildFlag_VerboseErrors:
|
case BuildFlag_VerboseErrors:
|
||||||
build_context.show_error_line = true;
|
gb_printf_err("-verbose-errors is not the default, -terse-errors can now disable it\n");
|
||||||
|
build_context.hide_error_line = false;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case BuildFlag_ErrorPosStyle:
|
case BuildFlag_ErrorPosStyle:
|
||||||
|
|||||||
Reference in New Issue
Block a user