avoid "if ... else if ... else" logic in ada-lang.c::ada_evaluate_subexp
authorJoel Brobecker <brobecker@adacore.com>
Thu, 14 Aug 2014 20:36:24 +0000 (13:36 -0700)
committerJoel Brobecker <brobecker@adacore.com>
Mon, 18 Aug 2014 15:09:33 +0000 (17:09 +0200)
The OP_VAR_VALUE branch in ada_evaluate_subexp is written with
multiple "if ... else if ... else if ... else ..." block. But
in practice, these blocks  all either goto out of that block of
code, or return.

This patch rewrites this code slightly by replacing the "else if"-s
by simple "if"s. This should better reflect the ideal processing
where we try to do a standard eval whenever possible, and only
do something else when the standard eval does not work. On a pratical
level, this patch makes it easier to fall through to the default
processing when none of the special situations are detected, thus
making it easier to add more handlers of those special situations;
or to remove them as they no longer become necessary!

gdb/ChangeLog:

        * ada-lang.c (ada_evaluate_subexp) <OP_VAR_VALUE>: Slight code
        rewrite to avoid "else if" and "else" constructs.  Should be
        a no-op in practice.

gdb/ChangeLog
gdb/ada-lang.c

index 8cb2f18c7a24b187ce58893958bef4cc2684e88a..23bc2149728a510efdb274199c20ac7dd7bdcb19 100644 (file)
@@ -1,3 +1,9 @@
+2014-08-18  Joel Brobecker  <brobecker@adacore.com>
+
+       * ada-lang.c (ada_evaluate_subexp) <OP_VAR_VALUE>: Slight code
+       rewrite to avoid "else if" and "else" constructs.  Should be
+       a no-op in practice.
+
 2014-08-18  Joel Brobecker  <brobecker@adacore.com>
 
        * ada-lang.c (ada_evaluate_subexp) <OP_VAR_VALUE>: Fix identation
index 334df1f8be8f674a908171eba363e1dd0c7dbadb..a9b5e6f2f80a95f7458a23f83b35908a67af925a 100644 (file)
@@ -10121,13 +10121,15 @@ ada_evaluate_subexp (struct type *expect_type, struct expression *exp,
           *pos += 4;
           goto nosideret;
         }
-      else if (SYMBOL_DOMAIN (exp->elts[pc + 2].symbol) == UNDEF_DOMAIN)
+
+      if (SYMBOL_DOMAIN (exp->elts[pc + 2].symbol) == UNDEF_DOMAIN)
         /* Only encountered when an unresolved symbol occurs in a
            context other than a function call, in which case, it is
            invalid.  */
         error (_("Unexpected unresolved symbol, %s, during evaluation"),
                SYMBOL_PRINT_NAME (exp->elts[pc + 2].symbol));
-      else if (noside == EVAL_AVOID_SIDE_EFFECTS)
+
+      if (noside == EVAL_AVOID_SIDE_EFFECTS)
         {
           type = static_unwrap_type (SYMBOL_TYPE (exp->elts[pc + 2].symbol));
           /* Check to see if this is a tagged type.  We also need to handle
@@ -10186,11 +10188,9 @@ ada_evaluate_subexp (struct type *expect_type, struct expression *exp,
           *pos += 4;
           return value_zero (to_static_fixed_type (type), not_lval);
         }
-      else
-        {
-          arg1 = evaluate_subexp_standard (expect_type, exp, pos, noside);
-          return ada_to_fixed_value (arg1);
-        }
+
+      arg1 = evaluate_subexp_standard (expect_type, exp, pos, noside);
+      return ada_to_fixed_value (arg1);
 
     case OP_FUNCALL:
       (*pos) += 2;
This page took 0.048898 seconds and 4 git commands to generate.