[PATCH] D17034: Add an AST matcher for null pointers

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Tue Feb 9 11:38:17 PST 2016


aaron.ballman added inline comments.

================
Comment at: include/clang/ASTMatchers/ASTMatchers.h:4821
@@ +4820,3 @@
+///   initializer for i.
+AST_MATCHER(Expr, nullPointerConstant) {
+  return Matcher<Expr>(
----------------
sbenza wrote:
> sbenza wrote:
> > Use AST_MATCHER_FUNCTION instead, where the return value is the matcher (instead of the application of the matcher).
> > It is simpler to write and since it has no arguments it will memoize the matcher and construct it only once.
> Maybe use Expr::isNullPointerConstant?
Ah, interesting! I hadn't known about that macro. Thank you.

================
Comment at: include/clang/ASTMatchers/ASTMatchers.h:4821
@@ +4820,3 @@
+///   initializer for i.
+AST_MATCHER(Expr, nullPointerConstant) {
+  return Matcher<Expr>(
----------------
aaron.ballman wrote:
> sbenza wrote:
> > sbenza wrote:
> > > Use AST_MATCHER_FUNCTION instead, where the return value is the matcher (instead of the application of the matcher).
> > > It is simpler to write and since it has no arguments it will memoize the matcher and construct it only once.
> > Maybe use Expr::isNullPointerConstant?
> Ah, interesting! I hadn't known about that macro. Thank you.
Oh, hey, that's easier still! Would I still use AST_MATCHER_FUNCTION in that case though, or should that remain a simple AST_MATCHER?


http://reviews.llvm.org/D17034





More information about the cfe-commits mailing list