This is an archive of the discontinued LLVM Phabricator instance.

NFC: Simplify dumpStmt child handling
ClosedPublic

Authored by steveire on Nov 29 2018, 11:35 AM.

Diff Detail

Repository
rL LLVM

Event Timeline

steveire created this revision.Nov 29 2018, 11:35 AM
aaron.ballman added inline comments.Nov 29 2018, 12:15 PM
lib/AST/ASTDumper.cpp
1987 ↗(On Diff #175911)

Was there something special about calling the Visit methods directly and bailing out? Your code certainly looks reasonable, but I wonder if the output is changed because it goes through the ConstStmtVisitor instead of directly dispatching.

1990 ↗(On Diff #175911)

These should be isa<> checks instead of dyn_cast<> checks.

steveire updated this revision to Diff 175956.Nov 29 2018, 2:04 PM

Use isa instead of dyn_cast

steveire marked 2 inline comments as done.Nov 29 2018, 2:06 PM
steveire added inline comments.
lib/AST/ASTDumper.cpp
1987 ↗(On Diff #175911)

I don't think it could have changed. By my understanding of the StmtVisitor, this has the same effect.

aaron.ballman added inline comments.Nov 30 2018, 5:35 AM
lib/AST/ASTDumper.cpp
1987 ↗(On Diff #175911)

Yeah, I don't see how it would either, but the original code smells suspicious to me. How about adding some tests for DeclStmt and GenericSelectionExpr that demonstrates explicitly this isn't changing behavior?

In fact, it seems that we have some bugs in this area (with DeclStmt) already, so understanding what's changing may point out fixes. https://godbolt.org/z/tDJ-0H

steveire marked an inline comment as done.Nov 30 2018, 6:17 AM
steveire added inline comments.
lib/AST/ASTDumper.cpp
1987 ↗(On Diff #175911)

A visual inspection and reading of the visitor should show that this patch is NFC. I'd welcome a test if you can make one. The test should be in the repo before this commit anyway.

In fact, it seems that we have some bugs in this area (with DeclStmt) already, so understanding what's changing may point out fixes. https://godbolt.org/z/tDJ-0H

That is not related to this refactoring.

Also, clang-query has different output:

http://ec2-52-14-16-249.us-east-2.compute.amazonaws.com:10240/z/W_kZFl

Aaron, you added tests for the existing behavior which pass after this patch. Is there anything holding it up?

aaron.ballman accepted this revision.Dec 3 2018, 4:33 AM

Aaron, you added tests for the existing behavior which pass after this patch. Is there anything holding it up?

Nope, I was just waiting on confirmation that the behavior hadn't changed. Thanks for letting me know!

LGTM!

This revision is now accepted and ready to land.Dec 3 2018, 4:33 AM
This revision was automatically updated to reflect the committed changes.