[PATCH] D17986: [ASTMatchers] Existing matcher hasAnyArgument fixed and new matcher hasReturnValue added
Samuel Benzaquen via cfe-commits
cfe-commits at lists.llvm.org
Fri Mar 11 07:57:30 PST 2016
sbenza added a comment.
The reason we haven't fixed hasAnyArgument is that it can potentially break its users.
I'd prefer if you separated the fix from the addition.
That way we can revert the fix if needed.
================
Comment at: include/clang/ASTMatchers/ASTMatchers.h:4796
@@ +4795,3 @@
+/// \endcode
+/// hasReturnValue(binaryOperator())
+/// matches 'return a+b'
----------------
New matchers must be tested.
See ASTMatchersTest.cpp.
Also, they should be added to the dynamic registry.
See Dynamic/Registry.cpp
================
Comment at: include/clang/ASTMatchers/ASTMatchers.h:4800
@@ +4799,3 @@
+/// matching 'a+b'
+AST_MATCHER_P(ReturnStmt, hasReturnValue, internal::Matcher<Expr>, InnerMatcher) {
+ BoundNodesTreeBuilder Result(*Builder);
----------------
I'm not sure this is needed.
`returnStmt(hasReturnValue(...))` is equivalent to `returnStmt(has(...))`
There are many checks using the latter already.
http://reviews.llvm.org/D17986
More information about the cfe-commits
mailing list