[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
Mon Jan 11 06:33:40 PST 2021


aaron.ballman added inline comments.


================
Comment at: clang/include/clang/ASTMatchers/ASTMatchersInternal.h:1994
+      return None;
+    return FD->getNumParams() > 0 ? UO_PostInc : UO_PreInc;
+  }
----------------
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.


================
Comment at: clang/include/clang/ASTMatchers/ASTMatchersInternal.h:2142-2150
+  auto optBinaryOpcode = equivalentBinaryOperator(Node);
+  if (!optBinaryOpcode) {
+    auto optUnaryOpcode = equivalentUnaryOperator(Node);
+    if (!optUnaryOpcode) {
+      return false;
+    }
+    return Name == UnaryOperator::getOpcodeStr(*optUnaryOpcode);
----------------
Can we reuse the implementation from `getOpName()` to simplify this?


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