This is an archive of the discontinued LLVM Phabricator instance.

Re-order content in OMPDeclareReductionDecl dump
ClosedPublic

Authored by steveire on Dec 6 2018, 3:31 PM.

Diff Detail

Repository
rL LLVM

Event Timeline

steveire created this revision.Dec 6 2018, 3:31 PM
ABataev requested changes to this revision.Dec 6 2018, 4:04 PM
ABataev added a subscriber: ABataev.

This is wrong, the original implementation is correct and should not be changed.

This revision now requires changes to proceed.Dec 6 2018, 4:04 PM
rsmith added a subscriber: rsmith.Dec 6 2018, 7:36 PM

This is wrong, the original implementation is correct and should not be changed.

The original implementation looks pretty clearly wrong to me, but I think this is wrong too. It looks like what was intended here was probably to label the two children as "combiner" and "initializer" respectively. As-is, the "combiner" text on the OMPDeclareReductionDecl line means nothing at all.

This is wrong, the original implementation is correct and should not be changed.

The original implementation looks pretty clearly wrong to me, but I think this is wrong too. It looks like what was intended here was probably to label the two children as "combiner" and "initializer" respectively. As-is, the "combiner" text on the OMPDeclareReductionDecl line means nothing at all.

Oh yes, agree. Still must be reworked.

steveire updated this revision to Diff 177420.Dec 9 2018, 6:08 AM

Use child node labels

This is a novel approach that's not used anywhere else in the AST dumper and there are several ways we could handle this, including:

Why this way?

I'm not a huge fan of adding a new node to the tree that's not an AST node. It expands the tree both vertically (by adding a new node) and horizontally (by indenting everything below that new node) which I find visually distracting for the benefit provided. I personally prefer using the pointer information as it's less structurally disruptive and still provides the same information. I also find it a bit easier to match nodes up that way because the indentation level and tree-like adornments sometimes make it hard for me to determine relationships between when spatially far apart in the tree. There is precedence for using labels + pointers in the AST dumper already -- this is how we handle the prev and parent nodes for declarations, for instance.

If we're going to invent a novel way to do this, I do not think it should be done in an ad hoc manner, but should instead talk about whether we want to see this done in a more uniform fashion. For instance, how is this information any different than the list of overrides for a method, the previous declaration in a redecl, the parent of an out-of-line function definition, where a default template argument is inherited from, etc (all of which use pointers for relationships)? I don't feel the same way if we go with an existing practice that incrementally improves consistency.

This is a novel approach that's not used anywhere else in the AST dumper

Actually it's used by the InitListExpr dump. See https://reviews.llvm.org/D55488

This is a novel approach that's not used anywhere else in the AST dumper and there are several ways we could handle this, including:

Why this way?

I'm not a huge fan of adding a new node to the tree that's not an AST node. It expands the tree both vertically (by adding a new node) and horizontally (by indenting everything below that new node) which I find visually distracting for the benefit provided. I personally prefer using the pointer information as it's less structurally disruptive and still provides the same information. I also find it a bit easier to match nodes up that way because the indentation level and tree-like adornments sometimes make it hard for me to determine relationships between when spatially far apart in the tree. There is precedence for using labels + pointers in the AST dumper already -- this is how we handle the prev and parent nodes for declarations, for instance.

If we're going to invent a novel way to do this, I do not think it should be done in an ad hoc manner, but should instead talk about whether we want to see this done in a more uniform fashion. For instance, how is this information any different than the list of overrides for a method, the previous declaration in a redecl, the parent of an out-of-line function definition, where a default template argument is inherited from, etc (all of which use pointers for relationships)? I don't feel the same way if we go with an existing practice that incrementally improves consistency.

I personally also prefer the first one. However is this really needed in this case ? The first sub-node will always be the combiner,
and then the second node will the the initializer if present. It seems to me that there is no ambiguity here.

I would prefer *not* to do what is in this patch. I'm just trying to find a way forward. I like the approach of using the existing precedent of printing the pointers as a compromise between removing such labels entirely and not having things like that at all. I did that for InitListExpr here: https://reviews.llvm.org/D55495

steveire updated this revision to Diff 177428.Dec 9 2018, 7:34 AM

Use pointer approach

aaron.ballman accepted this revision.Dec 9 2018, 9:01 AM

LGTM with a small nit. @ABataev, are you okay with this approach?

lib/AST/ASTDumper.cpp
1060 ↗(On Diff #177428)

Elide braces and may as well make this const auto *. (If you want to hit the one above, that would also be good -- maybe even hoist the call into an initializer for a local variable to be used in both places?)

ABataev added inline comments.Dec 10 2018, 8:24 AM
lib/AST/ASTDumper.cpp
1056 ↗(On Diff #177428)

Better to output it immediately after initializer keyword.

This revision was not accepted when it landed; it landed in state Needs Review.Dec 10 2018, 12:56 PM
This revision was automatically updated to reflect the committed changes.