diff options
| author | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2017-01-29 12:34:08 +0100 |
|---|---|---|
| committer | Christopher Li <sparse@chrisli.org> | 2017-02-13 09:34:45 +0800 |
| commit | 05adbae426c87e6f644ebb7eca95a2d66a190048 (patch) | |
| tree | 4eb94d924dc5d5e12f08da2f166d16d82438e294 | |
| parent | d1de74fffc9dcc7cd5eecf05b69d3df8091a4b3b (diff) | |
| download | sparse-dev-05adbae426c87e6f644ebb7eca95a2d66a190048.tar.gz | |
add helper: is_scalar_type()
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Signed-off-by: Christopher Li <sparse@chrisli.org>
| -rw-r--r-- | symbol.h | 22 |
1 files changed, 22 insertions, 0 deletions
@@ -374,6 +374,28 @@ static inline int is_bool_type(struct symbol *type) return type == &bool_ctype; } +static inline int is_scalar_type(struct symbol *type) +{ + if (type->type == SYM_NODE) + type = type->ctype.base_type; + switch (type->type) { + case SYM_ENUM: + case SYM_BITFIELD: + case SYM_PTR: + case SYM_ARRAY: // OK, will be a PTR after conversion + case SYM_FN: + case SYM_RESTRICT: // OK, always integer types + return 1; + default: + break; + } + if (type->ctype.base_type == &int_type) + return 1; + if (type->ctype.base_type == &fp_type) + return 1; + return 0; +} + static inline int is_function(struct symbol *type) { return type && type->type == SYM_FN; |
