Print this page
new smatch

@@ -30,11 +30,14 @@
 #include "allocate.h"
 #include "token.h"
 #include "parse.h"
 #include "symbol.h"
 #include "expression.h"
+#include "evaluate.h"
 
+static void copy_statement(struct statement *src, struct statement *dst);
+
 static struct expression * dup_expression(struct expression *expr)
 {
         struct expression *dup = alloc_expression(expr->pos, expr->type);
         *dup = *expr;
         return dup;

@@ -176,18 +179,18 @@
 
         /* Conditional expression */
         case EXPR_SELECT:
         case EXPR_CONDITIONAL: {
                 struct expression *cond = copy_expression(expr->conditional);
-                struct expression *true = copy_expression(expr->cond_true);
-                struct expression *false = copy_expression(expr->cond_false);
-                if (cond == expr->conditional && true == expr->cond_true && false == expr->cond_false)
+                struct expression *valt = copy_expression(expr->cond_true);
+                struct expression *valf = copy_expression(expr->cond_false);
+                if (cond == expr->conditional && valt == expr->cond_true && valf == expr->cond_false)
                         break;
                 expr = dup_expression(expr);
                 expr->conditional = cond;
-                expr->cond_true = true;
-                expr->cond_false = false;
+                expr->cond_true = valt;
+                expr->cond_false = valf;
                 break;
         }
 
         /* Statement expression */
         case EXPR_STATEMENT: {

@@ -269,10 +272,16 @@
                                 expr->index = idx;
                         }
                 }
                 break;
         }
+        case EXPR_ASM_OPERAND: {
+                expr = dup_expression(expr);
+                expr->constraint = copy_expression(expr->constraint);
+                expr->expr = copy_expression(expr->expr);
+                break;
+        }
         default:
                 warning(expr->pos, "trying to copy expression type %d", expr->type);
         }
         return expr;
 }

@@ -279,24 +288,13 @@
 
 static struct expression_list *copy_asm_constraints(struct expression_list *in)
 {
         struct expression_list *out = NULL;
         struct expression *expr;
-        int state = 0;
 
         FOR_EACH_PTR(in, expr) {
-                switch (state) {
-                case 0: /* identifier */
-                case 1: /* constraint */
-                        state++;
-                        add_expression(&out, expr);
-                        continue;
-                case 2: /* expression */
-                        state = 0;
                         add_expression(&out, copy_expression(expr));
-                        continue;
-                }
         } END_FOR_EACH_PTR(expr);
         return out;
 }
 
 static void set_replace(struct symbol *old, struct symbol *new)

@@ -367,24 +365,24 @@
                 stmt = new;
                 break;
         }
         case STMT_IF: {
                 struct expression *cond = stmt->if_conditional;
-                struct statement *true = stmt->if_true;
-                struct statement *false = stmt->if_false;
+                struct statement *valt = stmt->if_true;
+                struct statement *valf = stmt->if_false;
 
                 cond = copy_expression(cond);
-                true = copy_one_statement(true);
-                false = copy_one_statement(false);
+                valt = copy_one_statement(valt);
+                valf = copy_one_statement(valf);
                 if (stmt->if_conditional == cond &&
-                    stmt->if_true == true &&
-                    stmt->if_false == false)
+                    stmt->if_true == valt &&
+                    stmt->if_false == valf)
                         break;
                 stmt = dup_statement(stmt);
                 stmt->if_conditional = cond;
-                stmt->if_true = true;
-                stmt->if_false = false;
+                stmt->if_true = valt;
+                stmt->if_false = valf;
                 break;
         }
         case STMT_RETURN: {
                 struct expression *retval = copy_expression(stmt->ret_value);
                 struct symbol *sym = copy_symbol(stmt->pos, stmt->ret_target);

@@ -466,11 +464,11 @@
  * We do this for the tree-level inliner.
  *
  * This doesn't do the symbol replacement right: it's not
  * re-entrant.
  */
-void copy_statement(struct statement *src, struct statement *dst)
+static void copy_statement(struct statement *src, struct statement *dst)
 {
         struct statement *stmt;
 
         FOR_EACH_PTR(src->stmts, stmt) {
                 add_statement(&dst->stmts, copy_one_statement(stmt));