diff options
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 |