[clang-tools-extra] [clang-tidy] Unsafe CRTP check (PR #82403)
via cfe-commits
cfe-commits at lists.llvm.org
Tue Feb 20 12:51:33 PST 2024
================
@@ -0,0 +1,232 @@
+// RUN: %check_clang_tidy %s bugprone-unsafe-crtp %t
+
+namespace class_implicit_ctor {
+template <typename T>
+class CRTP {};
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: the implicit default constructor of the CRTP is publicly accessible [bugprone-unsafe-crtp]
+// CHECK-MESSAGES: :[[@LINE-2]]:7: note: consider making it private
----------------
isuckatcs wrote:
In this case the other warning is triggered. I didn't want to concatenate multiple warnings and fixes, because I don't think I've seen it happen with other clang-tidy checks either, but that might just be me not paying enough attention.
```
warning: the CRTP cannot be constructed from the derived class [bugprone-unsafe-crtp]
1 | template <typename T> class CRTP {
| ^
2 | private:
3 | CRTP() = default;
4 | };
note: consider declaring the derived class as friend
```
https://github.com/llvm/llvm-project/pull/82403
More information about the cfe-commits
mailing list