|4042 ↗||(On Diff #76014)|
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?
FWIW, a non-owner LGTM:
- CXXNewExpr seems very similar to CallExpr, so it makes sense that hasDeclaration would behave similarily for both of these expressions (i.e. matching the "callee")
- The issues we've been trying to work through in https://reviews.llvm.org/D24361 mainly revolve around Type and QualType, so I think those issues should not apply to CXXNewExpr matching.