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

Piotr Zegar via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Jul 18 23:37:58 PDT 2023


PiotrZSL 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:
> > 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).


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