Skip to content

Commit 2ce9fe7

Browse files
committed
fix comment
1 parent 322a819 commit 2ce9fe7

File tree

5 files changed

+17
-16
lines changed

5 files changed

+17
-16
lines changed

clang-tools-extra/clang-tidy/bugprone/ReturnConstRefFromParameterCheck.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ void ReturnConstRefFromParameterCheck::check(
2727
const MatchFinder::MatchResult &Result) {
2828
const auto *R = Result.Nodes.getNodeAs<ReturnStmt>("ret");
2929
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");
3232
}
3333

3434
} // namespace clang::tidy::bugprone

clang-tools-extra/clang-tidy/bugprone/ReturnConstRefFromParameterCheck.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@
1313

1414
namespace clang::tidy::bugprone {
1515

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.
1919
///
2020
/// For the user-facing documentation see:
2121
/// http://clang.llvm.org/extra/clang-tidy/checks/bugprone/return-const-ref-from-parameter.html

clang-tools-extra/docs/ReleaseNotes.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,9 @@ New checks
115115
- New :doc:`bugprone-return-const-ref-from-parameter
116116
<clang-tidy/checks/bugprone/return-const-ref-from-parameter>` check.
117117

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.
120121

121122
- New :doc:`bugprone-suspicious-stringview-data-usage
122123
<clang-tidy/checks/bugprone/suspicious-stringview-data-usage>` check.

clang-tools-extra/docs/clang-tidy/checks/bugprone/return-const-ref-from-parameter.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
bugprone-return-const-ref-from-parameter
44
========================================
55

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.
99

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,
1212
then the returned reference can be used after the object it refers to has been
1313
destroyed.
1414

clang-tools-extra/test/clang-tidy/checkers/bugprone/return-const-ref-from-parameter.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,16 @@ using TConstRef = int const&;
77
namespace invalid {
88

99
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
1111

1212
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
1414

1515
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
1717

1818
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
2020

2121
} // namespace invalid
2222

0 commit comments

Comments
 (0)