[PATCH] D120949: [clang][AST matchers] adding attributedStmt AST matcher
Johannes Doerfert via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Mar 7 21:53:33 PST 2022
jdoerfert added inline comments.
================
Comment at: clang/include/clang/ASTMatchers/ASTMatchers.h:2713-2714
+/// \endcode
+extern const internal::VariadicDynCastAllOfMatcher<Stmt, AttributedStmt>
+ attributedStmt;
+
----------------
aaron.ballman wrote:
> Design-wise, I'm on the fence here. AST matchers match the AST nodes that Clang produces, and from that perspective, this makes a lot of sense. But `AttributedStmt` is a bit of a hack in some ways, and do we want to expose that hack to AST matcher users? e.g., is there a reason we shouldn't make `returnStmt(hasAttr(attr::Likely))` work directly rather than making the user pick their way through the `AttributedStmt`? This is more in line with how you check for a declaration with a particular attribute and seems like the more natural way to surface this.
>
> For the moment, since this is following the current AST structure in Clang, I think this is fine. But I'm curious if @klimek or perhaps @sammccall has an opinion here.
I think a way to find any kind of statement (or expression) that has a specific attribute is very useful. How that should look, idk.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D120949/new/
https://reviews.llvm.org/D120949
More information about the cfe-commits
mailing list