diff options
author | dec05eba <dec05eba@protonmail.com> | 2019-08-01 20:36:51 +0200 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2020-07-25 14:36:46 +0200 |
commit | 4ca3b74621c3608de42a91730a71892d9d7c27b5 (patch) | |
tree | ae6ed7a1c37fc7fe32b3f763b839e65fe6becbeb /include | |
parent | 0f26e1d204d3a3026ca3edfc4c6bd9638b2632e7 (diff) |
Remove nullable... it's bad to have magic. Static analysis can do it instead
Diffstat (limited to 'include')
-rw-r--r-- | include/ast.h | 4 | ||||
-rw-r--r-- | include/nullable.h | 24 |
2 files changed, 3 insertions, 25 deletions
diff --git a/include/ast.h b/include/ast.h index 6a40980..9f01b1b 100644 --- a/include/ast.h +++ b/include/ast.h @@ -88,8 +88,6 @@ struct Ast { SsaRegister ssa_reg; }; -DefineNullablePtrType(Ast); - struct Scope { Buffer/*<Ast*>*/ ast_objects; HashMap/*(key=BufferView, value=Ast<LhsExpr>*)*/ named_objects; @@ -160,7 +158,7 @@ struct LhsExpr { bool is_const; BufferView var_name; VariableType type; - NullablePtr(Ast) rhs_expr; + Ast *rhs_expr; }; struct AssignmentExpr { diff --git a/include/nullable.h b/include/nullable.h index 6c4d3a7..f84100b 100644 --- a/include/nullable.h +++ b/include/nullable.h @@ -3,27 +3,7 @@ struct __nullable_type_dummy{ int _; }; -int assert_not_null(void *val); - -#ifdef DEBUG -#define DefineNullablePtrType(type) \ - typedef struct type##_nullable type##_nullable; \ - struct type##_nullable { \ - type *value; \ - } -#define NullablePtr(type) type##_nullable -#define nullable_unwrap(nullable_type) \ - (assert_not_null((nullable_type).value) ? ((nullable_type).value) : NULL) -#define nullable_assign(nullable_type, new_value) ((nullable_type).value = (new_value)) -#define is_not_null(nullable_type) ((nullable_type).value != NULL) -#define nullable_raw(nullable_type) ((nullable_type).value) -#else -#define DefineNullablePtrType(type) -#define NullablePtr(type) type* -#define nullable_unwrap(value) value -#define nullable_assign(nullable_type, new_value) ((nullable_type) = (new_value)) -#define is_not_null(nullable_type) ((nullable_type) != NULL) -#define nullable_raw(nullable_type) (nullable_type) -#endif +/* Used by static analysis tool to find null-pointer dereference errors */ +#define nullable #endif |