[PATCH] D94865: [ASTMatchers] Add callOrConstruct matcher

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Jan 19 06:18:12 PST 2021


aaron.ballman added inline comments.


================
Comment at: clang/include/clang/ASTMatchers/ASTMatchers.h:2867
+extern const internal::MapAnyOfMatcher<CallExpr, CXXConstructExpr>
+    callOrConstruct;
+
----------------
I'm not super keen on this name. It's certainly descriptive, but I do wonder if it's a bit too specific and should perhaps be something more like `callableExpr()`, `callLikeExpr()`, or something more generic. For instance, I could imagine wanting this to match on something like:
```
struct S {
  void setter(int val) {}
  __declspec(property(put = setter)) int x;
};

int main() {
  S s;
  s.x = 12; // Match here
  // Because the above code actually does this:
  // s.setter(12);
}
```
because this also has an expression that isn't really a call (as far as our AST is concerned) but is a call as far as program semantics are concerned. I'm not suggesting to make the matcher support that right now (unless you felt like doing it), but thinking about the future and avoiding a name that may paint us into a corner.

WDYT about using a more generic name?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94865



More information about the cfe-commits mailing list