PiotrZSL added inline comments.
================ Comment at: clang-tools-extra/clang-tidy/cppcoreguidelines/AvoidReferenceCoroutineParametersCheck.cpp:20 + Finder->addMatcher( + functionDecl(unless(parameterCountIs(0)), hasBody(coroutineBodyStmt())) + .bind("fnt"), ---------------- ccotter wrote: > Can we do this by matching if any parameter is of reference type, rather than > relying on the logic living in `check` (I wrote this originally, although > perhaps this would be an improvement). Happy to take this up as a followup... Matching functionDecl first is cheaper... In theory using `hasParent` instead of `hasAncestor` should be sufficient, but I never trusted that relation. Something like this should do a trick also: ``` functionDecl(unless(parameterCountIs(0)), hasBody(coroutineBodyStmt()), forEach(parmVarDecl(hasType(qualType(hasCanonicalType( references(qualType()))))).bind("param")) ``` should also work, but I didn't test it. Current code will do a same thing, not using matchers should even make it faster, and `check` method is called only for coroutines. Personally I just prefer matcher to match nodes that we got less. This also enable other thing, like providing 1 warning per coroutine and additional notes for every parameter with parameter name in it. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D158665/new/ https://reviews.llvm.org/D158665 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits