From 7a4fdad6e866cc5775322531813973e1f5c1d393 Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Fri, 9 Jan 2015 14:17:34 +0300 Subject: [PATCH] comparison: handle preops like "if (++a == b)" The statement "if (++a == b)" is the same as "a++; if (a == b)" so at the end we know they are either equal or not. Signed-off-by: Dan Carpenter --- smatch_comparison.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/smatch_comparison.c b/smatch_comparison.c index c46f9964..28e6a687 100644 --- a/smatch_comparison.c +++ b/smatch_comparison.c @@ -680,6 +680,11 @@ static char *chunk_to_var_sym(struct expression *expr, struct symbol **sym) if (sym) *sym = NULL; + if (expr->type == EXPR_PREOP && + (expr->op == SPECIAL_INCREMENT || + expr->op == SPECIAL_DECREMENT)) + expr = strip_expr(expr->unop); + name = expr_to_var_sym(expr, &tmp); if (name && tmp) { if (sym) -- 2.11.4.GIT