================
@@ -0,0 +1,42 @@
+.. title:: clang-tidy - bugprone-misleading-setter-of-reference
+
+bugprone-misleading-setter-of-reference
+=======================================
+
+Finds setter-like functions that take a pointer parameter and set a (non-const)
+reference with the pointed value. The fact that a setter function takes a
+pointer might cause the belief that an internal reference (if it would be a
+pointer) is changed instead of the pointed-to (or referenced) value.
+
+Only member functions are detected which have a single parameter and contain a
+single (maybe overloaded) assignment operator call.
+
+Example:
+
+.. code-block:: c++
+
+  class Widget {
+    int& ref_;  // non-const reference member
+  public:
+    // non-copyable
+    Widget(const Widget&) = delete;
+    // non-movable
+    Widget(Widget&&) = delete;
+ 
----------------
NagyDonat wrote:

```suggestion
```

I understand that a class with a reference member is problematic if it doesn't 
disable the copy/move constructors, but there is no reason to explicitly spell 
out these deleted methods in this example, because they don't have a role in 
the problem that's reported by this checker.

If you want, you could add `// ...` at the end of the class definition to show 
that there are other methods (including these deleted ones) -- but I don't 
think that this is necessary.

https://github.com/llvm/llvm-project/pull/132242
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to