[PATCH] D155625: [clang-tidy] Warn only for copyable/movable classes in cppcoreguidelines-avoid-const-or-ref-members

Carlos Galvez via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Jul 19 05:01:53 PDT 2023


carlosgalvezp added inline comments.


================
Comment at: clang-tools-extra/clang-tidy/cppcoreguidelines/AvoidConstOrRefDataMembersCheck.cpp:91-102
+  Finder->addMatcher(
+      fieldDecl(unless(isMemberOfLambda()),
+                hasDeclContext(cxxRecordDecl(isCopyableOrMovable())),
+                hasType(hasCanonicalType(referenceType())))
+          .bind("ref"),
+      this);
+  Finder->addMatcher(
----------------
carlosgalvezp wrote:
> PiotrZSL wrote:
> > carlosgalvezp wrote:
> > > PiotrZSL wrote:
> > > > Check first type, should be cheaper and consider mering those two. 
> > > Thanks for the tip! I'm not familiar with having multiple binds in the same `addMatcher` call. Do I still need to keep the `bind("ref")` at the end?
> > No, bind at the end need to be removed (I forgot about that).
> Somehow I didn't manage to get it to work with your proposed change and removing `bind`, I feel I'm walking on thin ice here :) 
Doing it from scratch helped, probably some parenthesis that was off!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155625



More information about the cfe-commits mailing list