aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
authorLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2017-01-29 12:34:08 +0100
committerChristopher Li <sparse@chrisli.org>2017-02-13 09:34:45 +0800
commit05adbae426c87e6f644ebb7eca95a2d66a190048 (patch)
tree4eb94d924dc5d5e12f08da2f166d16d82438e294
parentd1de74fffc9dcc7cd5eecf05b69d3df8091a4b3b (diff)
downloadsparse-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.h22
1 files changed, 22 insertions, 0 deletions
diff --git a/symbol.h b/symbol.h
index 51be81fb..947a66d2 100644
--- a/symbol.h
+++ b/symbol.h
@@ -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;