mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
Asserts are now correctly included and traced in when running tests. Removed accidental debug trace.
This commit is contained in:
@@ -23,6 +23,7 @@
|
||||
- Fix regression for `$include`.
|
||||
- Correct '.so' suffix on dynamic libraries on Linux.
|
||||
- Fix bug where inline index access to array in a struct would crash the compiler.
|
||||
- Asserts are now correctly included and traced in when running tests.
|
||||
|
||||
### Stdlib changes
|
||||
- Additional init functions for hashmap.
|
||||
|
||||
@@ -1931,6 +1931,11 @@ INLINE bool no_stdlib(void)
|
||||
return compiler.build.use_stdlib == USE_STDLIB_OFF;
|
||||
}
|
||||
|
||||
INLINE bool compile_asserts(void)
|
||||
{
|
||||
return safe_mode_enabled() || compiler.build.testing;
|
||||
}
|
||||
|
||||
bool ast_is_not_empty(Ast *ast);
|
||||
|
||||
bool ast_is_compile_time(Ast *ast);
|
||||
|
||||
@@ -2565,13 +2565,6 @@ static inline void llvm_emit_deref(GenContext *c, BEValue *value, Expr *inner, T
|
||||
if (safe_mode_enabled())
|
||||
{
|
||||
LLVMValueRef check = LLVMBuildICmp(c->builder, LLVMIntEQ, value->value, llvm_get_zero(c, inner->type), "checknull");
|
||||
assert(!LLVMIsPoison(check));
|
||||
if (llvm_is_const(check))
|
||||
{
|
||||
LLVMDumpValue(check);
|
||||
printf("-- %lld value\n", LLVMConstIntGetSExtValue(check));
|
||||
|
||||
}
|
||||
scratch_buffer_clear();
|
||||
scratch_buffer_append("Dereference of null pointer, '");
|
||||
span_to_scratch(inner->span);
|
||||
|
||||
@@ -1176,7 +1176,7 @@ static inline void llvm_emit_assert_stmt(GenContext *c, Ast *ast)
|
||||
{
|
||||
ExprId exprid = ast->assert_stmt.expr;
|
||||
Expr *assert_expr = exprptr(exprid);
|
||||
if (safe_mode_enabled() || compiler.build.testing)
|
||||
if (compile_asserts())
|
||||
{
|
||||
BEValue value;
|
||||
llvm_emit_expr(c, &value, assert_expr);
|
||||
|
||||
@@ -143,11 +143,11 @@ static void sema_trace_stmt_liveness(Ast *ast)
|
||||
case AST_ASSERT_STMT:
|
||||
{
|
||||
Expr *e = exprptr(ast->assert_stmt.expr);
|
||||
if (safe_mode_enabled() || expr_is_pure(e))
|
||||
if (compile_asserts() || expr_is_pure(e))
|
||||
{
|
||||
sema_trace_expr_liveness(e);
|
||||
}
|
||||
if (safe_mode_enabled())
|
||||
if (compile_asserts())
|
||||
{
|
||||
sema_trace_exprid_liveness(ast->assert_stmt.message);
|
||||
sema_trace_expr_list_liveness(ast->assert_stmt.args);
|
||||
|
||||
Reference in New Issue
Block a user