This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [Google] Fix discriminator assignment for stmts


> Please ignore the original patch, which is wrong. New patch updated,
> passed regression test.

+  for (i = next_discriminator_location - min_discriminator_location - 1;
+       i >= 0 && LOCATION_LINE (discriminator_location_locations[i]) ==
+ LOCATION_LINE (locus) &&
+       discriminator_location_discriminators[i] == discriminator; i--)
+    if (discriminator_location_locations[i] == locus)
+      return block ? COMBINE_LOCATION_DATA (
+  line_table, min_discriminator_location + i, block)
+  : min_discriminator_location + i;

As per GCC coding conventions, the long expressions need to be
parenthesized and indented under the parens, with operators at the
beginning of the line, like this:

+  for (i = next_discriminator_location - min_discriminator_location - 1;
+       (i >= 0
+        && (LOCATION_LINE (discriminator_location_locations[i])
+            == LOCATION_LINE (locus))
+        && discriminator_location_discriminators[i] == discriminator);
+       i--)
+    if (discriminator_location_locations[i] == locus)
+      return (block
+              ? COMBINE_LOCATION_DATA (line_table,
+                                       min_discriminator_location + i,
+                                       block)
+              : min_discriminator_location + i);

Same here:

+  ret = block ? COMBINE_LOCATION_DATA (
+       line_table, next_discriminator_location, block)
+       : next_discriminator_location;

Should be something like this:

+  ret = (block
+         ? COMBINE_LOCATION_DATA (line_table, next_discriminator_location,
+                                  block)
+         : next_discriminator_location);

(Although this last statement would probably read better as a regular
if statement.)

And here:

+      if (same_line_p (locus, stmt_locus))
+        gimple_set_location (
+           stmt, location_with_discriminator (stmt_locus, discriminator));

Should be something like this:

+      if (same_line_p (locus, stmt_locus))
+        gimple_set_location (stmt,
+                             location_with_discriminator (stmt_locus,
+                                                          discriminator));

Looks good with those changes. Thanks!

-cary


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]