[PATCH] D26032: [ASTMatcher] Add operatorNew matcher for cxxNewExpr

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Thu Oct 27 06:26:19 PDT 2016


aaron.ballman added a reviewer: sbenza.
aaron.ballman added a subscriber: sbenza.
aaron.ballman added inline comments.


================
Comment at: include/clang/ASTMatchers/ASTMatchers.h:4042
+/// \endcode
+AST_MATCHER_P(CXXNewExpr, operatorNew,
+              internal::Matcher<FunctionDecl>, InnerMatcher) {
----------------
Instead of adding a new traversal matcher for `operatorNew`, we could use the existing `hasDeclaration` traversal matcher and provide another overload for it.

The CXXNewExpr does expose the selected `operator delete` overload as well, so I'm not certain using `hasDeclaration` is perfect, but it was the first traversal matcher I could think of when trying to go from a new expression to the overloaded `operator new` declaration chosen for the expression (which is similar to `CallExpr` usage). @klimek or @sbenza, do you have a preference?


https://reviews.llvm.org/D26032





More information about the cfe-commits mailing list