aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
authorLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2017-07-04 14:19:01 +0200
committerLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2018-02-01 17:53:32 +0100
commitc376727487f988de9b5368e67e9bdcb2b59edde4 (patch)
tree33812a95d29f1fc4ec20fde56b19c73beda31bde
parent58346b848ce3febccbfb2e2db7ad4262f0630a97 (diff)
downloadsparse-dev-c376727487f988de9b5368e67e9bdcb2b59edde4.tar.gz
add helper: valid_type()
'bad_type' is used for ... bad types instead of NULL in order to avoid later lots of null-checking. Alas NULL is also often used and so we have to check for NULL and 'bad_ctype' when checking a type's validity. Add an helper: valid_type() to make the code a bit simpler. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
-rw-r--r--symbol.h5
1 files changed, 5 insertions, 0 deletions
diff --git a/symbol.h b/symbol.h
index fd574642..b4d1c2ac 100644
--- a/symbol.h
+++ b/symbol.h
@@ -309,6 +309,11 @@ extern void debug_symbol(struct symbol *);
extern void merge_type(struct symbol *sym, struct symbol *base_type);
extern void check_declaration(struct symbol *sym);
+static inline int valid_type(const struct symbol *ctype)
+{
+ return ctype && ctype != &bad_ctype;
+}
+
static inline struct symbol *get_base_type(const struct symbol *sym)
{
return examine_symbol_type(sym->ctype.base_type);