llvmbot wrote:

<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang-tidy

Author: Julian Schmidt (5chmidti)

<details>
<summary>Changes</summary>

Describe how the issue that is diagnosed by this check can be resolved.
Namely, by adding an overload for the xvalue case (`&amp;&amp;` parameter).

Fixes #<!-- -->107600


---
Full diff: https://github.com/llvm/llvm-project/pull/107641.diff


1 Files Affected:

- (modified) 
clang-tools-extra/docs/clang-tidy/checks/bugprone/return-const-ref-from-parameter.rst
 (+9) 


``````````diff
diff --git 
a/clang-tools-extra/docs/clang-tidy/checks/bugprone/return-const-ref-from-parameter.rst
 
b/clang-tools-extra/docs/clang-tidy/checks/bugprone/return-const-ref-from-parameter.rst
index f007dfe5499908..2349e51477b7de 100644
--- 
a/clang-tools-extra/docs/clang-tidy/checks/bugprone/return-const-ref-from-parameter.rst
+++ 
b/clang-tools-extra/docs/clang-tidy/checks/bugprone/return-const-ref-from-parameter.rst
@@ -12,6 +12,15 @@ after the call. When the function returns such a parameter 
also as constant refe
 then the returned reference can be used after the object it refers to has been
 destroyed.
 
+This issue can be resolved by declaring an overload of the problematic function
+where the ``const &`` parameter is instead declared as ``&&``. The developer 
has
+to ensure that the implementation of that function does not produce a
+use-after-free, the exact error that this check is warning against.
+Marking such an ``&&`` overload as ``deleted``, will silence the warning as 
+well. In the case of different ``const &`` parameters being returned depending
+on the control flow of the function, an overload where all problematic
+``const &`` parameters have been declared as ``&&`` will resolve the issue.
+
 Example
 -------
 

``````````

</details>


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

Reply via email to