[PATCH] D94128: [ASTMatchers] Make cxxOperatorCallExpr matchers API-compatible with n-ary operators

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Jan 15 04:56:26 PST 2021


aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM



================
Comment at: clang/include/clang/ASTMatchers/ASTMatchersInternal.h:1994
+      return None;
+    return FD->getNumParams() > 0 ? UO_PostInc : UO_PreInc;
+  }
----------------
steveire wrote:
> aaron.ballman wrote:
> > Not certain how much we want to care about it, but I think we need to check whether there's exactly one parameter of type `int` to meet the language rules for these to be replacement APIs: http://eel.is/c++draft/over.inc#1
> > 
> > e.g., the user could do something rather unlikely like: `int operator++(float);` for their overload and we're report it as being equivalent when it really isn't.
> It doesn't compile with the big three at least: https://godbolt.org/z/Kns8We
> 
> So, we can't write a test for it.
> 
> So, we shouldn't add a condition for it.
I had a think-o there and realize now that such a declaration is illegal per http://eel.is/c++draft/over.oper#over.inc-1

So agreed that we shouldn't handle it.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D94128/new/

https://reviews.llvm.org/D94128



More information about the cfe-commits mailing list