1// RUN: %check_clang_tidy %s bugprone-return-const-ref-from-parameter %t
2
3using T = int;
4using TConst = int const;
5using TConstRef = int const&;
6
7namespace invalid {
8
9int const &f1(int const &a) { return a; }
10// CHECK-MESSAGES: :[[@LINE-1]]:38: warning: returning a constant reference parameter
11
12int const &f2(T const &a) { return a; }
13// CHECK-MESSAGES: :[[@LINE-1]]:36: warning: returning a constant reference parameter
14
15int const &f3(TConstRef a) { return a; }
16// CHECK-MESSAGES: :[[@LINE-1]]:37: warning: returning a constant reference parameter
17
18int const &f4(TConst &a) { return a; }
19// CHECK-MESSAGES: :[[@LINE-1]]:35: warning: returning a constant reference parameter
20
21} // namespace invalid
22
23namespace valid {
24
25int const &f1(int &a) { return a; }
26
27int const &f2(int &&a) { return a; }
28
29int f1(int const &a) { return a; }
30
31} // namespace valid
32

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