[PATCH] D94126: [ASTMatchers] Make it possible to use empty variadic matchers

Stephen Kelly via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Jan 14 05:24:42 PST 2021


steveire added inline comments.


================
Comment at: clang/lib/ASTMatchers/ASTMatchersInternal.cpp:402
                                    ArrayRef<DynTypedMatcher> InnerMatchers) {
+  if (InnerMatchers.empty())
+    return true;
----------------
aaron.ballman wrote:
> Does it make sense to return `true` when there are no inner matchers? I would have thought that that if there are no matchers, nothing would match (so we'd return `false`)?
When debugging a matcher like

```
callExpr(anyOf(
    hasType(pointerType()),
    callee(functionDecl(hasName("foo")))
    ))
```

and commenting out inner matchers to get 

```
callExpr(anyOf(
#    hasType(pointerType()),
#    callee(functionDecl(hasName("foo")))
    ))
```

it would be very surprising for this to not match callExprs anymore.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94126



More information about the cfe-commits mailing list