This is an archive of the discontinued LLVM Phabricator instance.

Implement TemplateArgument dumping in terms of Visitor
ClosedPublic

Authored by steveire on Dec 9 2018, 5:50 AM.

Diff Detail

Repository
rL LLVM

Event Timeline

steveire created this revision.Dec 9 2018, 5:50 AM
aaron.ballman added inline comments.Jan 10 2019, 7:57 AM
include/clang/AST/TemplateArgumentVisitor.h
23 ↗(On Diff #180947)

std::add_lvalue_reference<> already does this, so do we really need this?

24 ↗(On Diff #180947)

I'm guessing we can't use std::add_lvalue_reference<std::add_const<>> for the same reasons we couldn't use it for pointers, but then make_const_ref should live in STLExtras.h and not here (it's generally useful).

27–28 ↗(On Diff #180947)

s/class/typename to be self-consistent

55 ↗(On Diff #180947)

Might be worth it to replace these with a macro, sort of like how DISPATCH is used above.

include/clang/AST/TextNodeDumper.h
156 ↗(On Diff #180947)

label -> Label and I think we should use a StringRef for the type.

lib/AST/ASTDumper.cpp
449–450 ↗(On Diff #180947)

llvm::for_each(TA.pack_elements(), ...); (or a range-based for loop)

lib/AST/TextNodeDumper.cpp
68 ↗(On Diff #180947)

label -> Label

73 ↗(On Diff #180947)

Elide braces

steveire marked an inline comment as done.Jan 10 2019, 9:31 AM
steveire added inline comments.
lib/AST/ASTDumper.cpp
449–450 ↗(On Diff #180947)

I'm just moving the code as it is in its origin location. You could rewrite it separately if you wish.

aaron.ballman added inline comments.Jan 10 2019, 9:50 AM
lib/AST/ASTDumper.cpp
449–450 ↗(On Diff #180947)

I realize that. You're updating existing code, which is a perfectly appropriate time for NFC improvements to it -- we make these kinds of requests frequently because it's the time at which we notice these minor deficiencies.

aaron.ballman accepted this revision.Jan 11 2019, 6:10 PM

Aside from nits that aren't complete yet, LGTM.

include/clang/AST/TemplateArgumentVisitor.h
24 ↗(On Diff #181395)

Missed a typename in there.

This revision is now accepted and ready to land.Jan 11 2019, 6:10 PM
thakis added a subscriber: thakis.Jan 11 2019, 6:20 PM

Out of interest, what's the motivation for this? It seems to add way more code than it removes, so there must be some other advantage, but the patch description doesn't say.

Out of interest, what's the motivation for this? It seems to add way more code than it removes, so there must be some other advantage, but the patch description doesn't say.

The reason for this is to split the output streaming from the traversal to other AST nodes.

This is a step as part of a larger refactoring with the aim of a class extracted from ASTDumper which does traversal but no streaming. That way, we can dump other output formats and do other things with the traversal.

steveire marked an inline comment as done.Jan 12 2019, 6:03 AM
steveire added inline comments.
include/clang/AST/TemplateArgumentVisitor.h
24 ↗(On Diff #181395)

If you're talking about the TTP, class must be used until C++17. See https://en.cppreference.com/w/cpp/language/template_parameters

This revision was automatically updated to reflect the committed changes.