This is an archive of the discontinued LLVM Phabricator instance.

Re-arrange content in FunctionDecl dump
ClosedPublic

Authored by steveire on Nov 29 2018, 3:18 PM.

Details

Summary

Output all content which is local to the FunctionDecl before traversing
to child AST nodes.

This is necessary so that all of the part which is local to the FunctionDecl can be split into a different method.

Diff Detail

Repository
rC Clang

Event Timeline

steveire created this revision.Nov 29 2018, 3:18 PM

The summary explains what it's doing, but not why it's doing it -- why is this change in behavior needed? Does this not break any tests?

Btw, as we work on this refactoring, I think a good approach will be to build up the base of tests around AST dumping so that we can be explicitly aware of any behavioral changes from the patches. We have some coverage, but it doesn't look to be particularly comprehensive. I am happy to contribute some of these tests. WDYT?

steveire edited the summary of this revision. (Show Details)Nov 30 2018, 6:18 AM

Yes, please commit your new tests for FunctionDecl dumping before this patch can go in.

Yes, please commit your new tests for FunctionDecl dumping before this patch can go in.

r347994 has those tests.

steveire updated this revision to Diff 177069.Dec 6 2018, 3:30 PM

Adjust tests

aaron.ballman added inline comments.Dec 7 2018, 4:56 AM
test/AST/ast-dump-decl.cpp
217 ↗(On Diff #177069)

I find this ordering to be confusing, especially because the template argument information is used by the parameter declaration type.

test/AST/ast-dump-funcs.cpp
59

I don't think this belongs at the start of the function -- the parameter information seems far more interesting than what the method overrides.

steveire marked an inline comment as done.Jan 15 2019, 4:08 AM
steveire added inline comments.
test/AST/ast-dump-funcs.cpp
59

Output does not occur in order of 'interesting-ness'.

aaron.ballman accepted this revision.Jan 15 2019, 11:57 AM

LGTM aside from some nit cleanup.

lib/AST/ASTDumper.cpp
648

Can switch to const auto *

649–651

Might as well switch this to use a range-based for loop over inits()

test/AST/ast-dump-funcs.cpp
59

Except that it kind of does occur in order of interesting-ness -- output occurs in whatever order is going to make the AST most understandable to the user.

My worry here is whether the parameter list will get "hidden" by the list of overrides, but I'm not certain this will be a problem in practice. I suspect there aren't a ton of deep class hierarchies with a lot of overrides for the same method across the entire hierarchy. I did some searching to see if I could find code examples in the wild where this output would be demonstrably worse, but I didn't find any, so I think this may be okay.

This revision is now accepted and ready to land.Jan 15 2019, 11:57 AM
This revision was automatically updated to reflect the committed changes.