Page MenuHomePhabricator

Implement Attr dumping in terms of visitors
ClosedPublic

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

Diff Detail

Event Timeline

steveire created this revision.Dec 9 2018, 5:50 AM
aaron.ballman added inline comments.Dec 9 2018, 10:23 AM
include/clang/AST/AttrVisitor.h
21

I don't think the namespace adds value.

23–24

Oh, this is cute. We have StmtVisitor which does not use a namespace, but defines these functions. Then we duplicate these function definitions in each of the comment, decl, and attribute visitors under distinct namespaces so we don't get ODR violations.

I think we should add llvm::make_const_ptr to STLExtras.h so we can use the same definition from everywhere. We can use std::add_pointer in place of make_ptr, because that is a one-to-one mapping, so we can drop make_ptr entirely. However, I don't think we can use std::add_pointer<std::add_const> similarly because there's no way to bind that to the template template parameter directly. I'm happy to make these changes if you'd like.

27

s/class/typename

include/clang/AST/TextNodeDumper.h
199

I'd appreciate some comments gently reminding the reader that this include introduces declarations which are expected to be members of a class.

lib/AST/ASTDumper.cpp
343

Similarly, add some comments about how this adds implementations to the class.

utils/TableGen/ClangAttrEmitter.cpp
3714

FunctionContent

3726

Wouldn't this be !FunctionContent.empty()?

3747

FunctionContent

steveire marked 3 inline comments as done.Dec 9 2018, 10:45 AM
steveire added inline comments.
include/clang/AST/AttrVisitor.h
21

I think the point is to separate the implementation detail. I don't care either way, but the other visitors should be changed first and this one can follow the same pattern.

23–24

Yes, I've thought about this duplication too. If you deduplicate, I'll rebase this change.

27

I think c++17 is the first to allow typename here.

aaron.ballman added inline comments.Dec 9 2018, 11:36 AM
include/clang/AST/AttrVisitor.h
21

Yeah, let's leave this in place and deal with it later.

23–24

Sounds good, I'll try to get that in shortly.

27

Huh, how neat. I'm fine leaving it as class if there are concerns about this being accepted by all our base compilers, it was a minor nit.

aaron.ballman added inline comments.Dec 9 2018, 11:57 AM
include/clang/AST/AttrVisitor.h
23–24

r348729 (LLVM) and r348730 (Clang).

steveire marked an inline comment as done.Jan 9 2019, 3:16 PM
steveire added inline comments.
utils/TableGen/ClangAttrEmitter.cpp
3726

I would have thought so, but apparently that's not how raw_string_ostream works. I get an empty file from this if I do that.

aaron.ballman added inline comments.Jan 10 2019, 7:41 AM
include/clang/AST/TextNodeDumper.h
115

Add a full stop to the end of the comment.

lib/AST/ASTDumper.cpp
93

This seems unrelated to this patch (same below) ?

333

Full stop here as well.

lib/AST/TextNodeDumper.cpp
48–49

Formatting is incorrect.

utils/TableGen/ClangAttrEmitter.cpp
3726

Huh, good to know.

3738

The source file comment will be incorrect. This emits the node traverser not the dumper.

steveire updated this revision to Diff 181182.Jan 10 2019, 4:12 PM
steveire marked an inline comment as done.

Nits

steveire added inline comments.Jan 10 2019, 4:12 PM
lib/AST/ASTDumper.cpp
93

These were called from the code which tablegen used to generate for dumping attrs. They're no longer needed after this change.

steveire marked an inline comment as done.Jan 10 2019, 4:14 PM
steveire added inline comments.
lib/AST/TextNodeDumper.cpp
48–49

Note that this is a scope for the color, not the opening of the function.

aaron.ballman accepted this revision.Jan 11 2019, 5:23 AM

LGTM!

lib/AST/ASTDumper.cpp
93

Ah, thank you for the explanation!

lib/AST/TextNodeDumper.cpp
48–49

Yup, my eyes glazed right over that.

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