[PATCH] D126880: [clang-tidy] Add cppcoreguidelines-avoid-const-or-ref-data-members check
David Friberg via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Jun 3 01:58:21 PDT 2022
dfrib added inline comments.
================
Comment at: clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-avoid-const-or-ref-data-members.cpp:25
+
+struct RefMember {
+ int &r;
----------------
Differentiate between lvalue reference and rvalue reference members using these terms instead of "ref" and "refref". E.g.:
- `RefMember` -> `LvalueRefMember`
- `RefRefMember` -> `RvalueRefMember`
(apply to all cases below).
================
Comment at: clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-avoid-const-or-ref-data-members.cpp:40
+
+struct ConstAndRefMember {
+ int const c;
----------------
`ConstAndRefMembers`
================
Comment at: clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-avoid-const-or-ref-data-members.cpp:100
+};
+
+template <typename T>
----------------
Should we test for array types also? E.g.:
```
template<int N> using Array = int[N];
struct ConstArrayMember {
const Array<1> c;
};
struct LvalueRefArrayMember {
Array<2>& lvr;
};
struct ConstRefArrayMember {
Array<3> const& clvr;
};
struct LvalueRefArrayMember {
Array<4>&& rvr;
};
```
================
Comment at: clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-avoid-const-or-ref-data-members.cpp:121
+TemplatedRef<int &&> t3{123};
+TemplatedOk<int> t4{};
----------------
Consider expanding with the the non-const lvalue ref case, e.g.
```
TemplatedOk<int> t4{};
TemplateRef<int&> t5{t4.t};
```
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D126880/new/
https://reviews.llvm.org/D126880
More information about the cfe-commits
mailing list