[clang-tools-extra] [tidy] add new check bugprone-return-const-ref-from-parameter (PR #89497)

Danny Mösch via cfe-commits cfe-commits at lists.llvm.org
Mon Apr 22 22:47:17 PDT 2024


================
@@ -112,6 +112,13 @@ New checks
   Detects error-prone Curiously Recurring Template Pattern usage, when the CRTP
   can be constructed outside itself and the derived class.
 
+- New :doc:`bugprone-return-const-ref-from-parameter
+  <clang-tidy/checks/bugprone/return-const-ref-from-parameter>` check.
+
+  Detects return statements that return constant reference parameter as constant
+  reference. This may cause use-after-free errors if the caller uses xvalue as
+  arguments.
----------------
SimplyDanny wrote:

```suggestion
  Detects return statements that return a constant reference parameter as constant
  reference. This may cause use-after-free errors if the caller uses xvalues as
  arguments.
```

https://github.com/llvm/llvm-project/pull/89497


More information about the cfe-commits mailing list