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