From a803618b1f49564ab7e82e65a4d4c3b2b63892db Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Mon, 28 Jan 2013 09:34:10 +0300 Subject: [PATCH] type: handle strings better Add EXPR_STRING to get_type. Also if it's a const string pointer then I don't want is_pointer() to return turn. The is_pointer() function is poorly named. It wants to know if the pointer is an lvalue. Signed-off-by: Dan Carpenter --- smatch_type.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/smatch_type.c b/smatch_type.c index 9426e4d8..2e50ec2e 100644 --- a/smatch_type.c +++ b/smatch_type.c @@ -190,6 +190,8 @@ struct symbol *get_type(struct expression *expr) expr = strip_parens(expr); switch (expr->type) { + case EXPR_STRING: + return &string_ctype; case EXPR_SYMBOL: return get_type_symbol(expr); case EXPR_DEREF: @@ -276,6 +278,8 @@ int is_pointer(struct expression *expr) sym = get_type(expr); if (!sym) return 0; + if (sym == &string_ctype) + return 0; if (sym->type == SYM_PTR) return 1; return 0; -- 2.11.4.GIT