File tree Expand file tree Collapse file tree 5 files changed +17
-16
lines changed Expand file tree Collapse file tree 5 files changed +17
-16
lines changed Original file line number Diff line number Diff line change @@ -27,8 +27,8 @@ void ReturnConstRefFromParameterCheck::check(
27
27
const MatchFinder::MatchResult &Result) {
28
28
const auto *R = Result.Nodes .getNodeAs <ReturnStmt>(" ret" );
29
29
diag (R->getRetValue ()->getBeginLoc (),
30
- " return const reference parameter cause potential use-after-free "
31
- " when function accepts immediately constructed value. " );
30
+ " returning a constant reference parameter may cause a use-after-free "
31
+ " when the parameter is constructed from a temporary " );
32
32
}
33
33
34
34
} // namespace clang::tidy::bugprone
Original file line number Diff line number Diff line change 13
13
14
14
namespace clang ::tidy::bugprone {
15
15
16
- // / Detects the function which returns the const reference parameter as const
17
- // / reference. This might causes potential use after free errors if the caller
18
- // / uses xvalue as arguments.
16
+ // / Detects return statements that return constant reference parameter as
17
+ // / constant reference. This may cause use- after- free errors if the caller uses
18
+ // / xvalue as arguments.
19
19
// /
20
20
// / For the user-facing documentation see:
21
21
// / http://clang.llvm.org/extra/clang-tidy/checks/bugprone/return-const-ref-from-parameter.html
Original file line number Diff line number Diff line change @@ -115,8 +115,9 @@ New checks
115
115
- New :doc: `bugprone-return-const-ref-from-parameter
116
116
<clang-tidy/checks/bugprone/return-const-ref-from-parameter>` check.
117
117
118
- Detects the function which returns the const reference from parameter which
119
- causes potential use after free if the caller uses xvalue as argument.
118
+ Detects return statements that return constant reference parameter as constant
119
+ reference. This may cause use-after-free errors if the caller uses xvalue as
120
+ arguments.
120
121
121
122
- New :doc: `bugprone-suspicious-stringview-data-usage
122
123
<clang-tidy/checks/bugprone/suspicious-stringview-data-usage>` check.
Original file line number Diff line number Diff line change 3
3
bugprone-return-const-ref-from-parameter
4
4
========================================
5
5
6
- Detects the function which returns the const reference parameter as const
7
- reference. This might causes potential use after free errors if the caller
8
- uses xvalue as arguments.
6
+ Detects return statements that return constant reference parameter as constant
7
+ reference. This may cause use- after- free errors if the caller uses xvalue as
8
+ arguments.
9
9
10
- In C++, const reference parameters can accept xvalues which will be destructed
11
- after the call. When the function returns such a parameter also as const reference,
10
+ In C++, constant reference parameters can accept xvalues which will be destructed
11
+ after the call. When the function returns such a parameter also as constant reference,
12
12
then the returned reference can be used after the object it refers to has been
13
13
destroyed.
14
14
Original file line number Diff line number Diff line change @@ -7,16 +7,16 @@ using TConstRef = int const&;
7
7
namespace invalid {
8
8
9
9
int const &f1 (int const &a) { return a; }
10
- // CHECK-MESSAGES: :[[@LINE-1]]:38: warning: return const reference parameter
10
+ // CHECK-MESSAGES: :[[@LINE-1]]:38: warning: returning a constant reference parameter
11
11
12
12
int const &f2 (T const &a) { return a; }
13
- // CHECK-MESSAGES: :[[@LINE-1]]:36: warning: return const reference parameter
13
+ // CHECK-MESSAGES: :[[@LINE-1]]:36: warning: returning a constant reference parameter
14
14
15
15
int const &f3 (TConstRef a) { return a; }
16
- // CHECK-MESSAGES: :[[@LINE-1]]:37: warning: return const reference parameter
16
+ // CHECK-MESSAGES: :[[@LINE-1]]:37: warning: returning a constant reference parameter
17
17
18
18
int const &f4 (TConst &a) { return a; }
19
- // CHECK-MESSAGES: :[[@LINE-1]]:35: warning: return const reference parameter
19
+ // CHECK-MESSAGES: :[[@LINE-1]]:35: warning: returning a constant reference parameter
20
20
21
21
} // namespace invalid
22
22
You can’t perform that action at this time.
0 commit comments