From c4b461454a6cd4095aecb6ffa5e3309cff6f64d2 Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Fri, 9 Dec 2011 09:25:23 +0300 Subject: [PATCH] type: add expr_unsigned() Returns true if the expression is unsigned. Signed-off-by: Dan Carpenter --- smatch.h | 1 + smatch_type.c | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/smatch.h b/smatch.h index 20598274..e49deb43 100644 --- a/smatch.h +++ b/smatch.h @@ -232,6 +232,7 @@ char *get_fnptr_name(struct expression *expr); /* smatch_type.c */ struct symbol *get_type(struct expression *expr); int type_unsigned(struct symbol *base_type); +int expr_unsigned(struct expression *expr); int returns_unsigned(struct symbol *base_type); int returns_pointer(struct symbol *base_type); long long type_max(struct symbol *base_type); diff --git a/smatch_type.c b/smatch_type.c index 2e0a00ce..e4a18186 100644 --- a/smatch_type.c +++ b/smatch_type.c @@ -138,6 +138,18 @@ int type_unsigned(struct symbol *base_type) return 0; } +int expr_unsigned(struct expression *expr) +{ + struct symbol *sym; + + sym = get_type(expr); + if (!sym) + return 0; + if (type_unsigned(sym)) + return 1; + return 0; +} + int returns_unsigned(struct symbol *sym) { if (!sym) -- 2.11.4.GIT