| Benjamin Kramer | b103975 | 2014-07-16 10:00:14 +0000 | [diff] [blame^] | 1 | // RUN: clang-tidy %s -checks='-*,google-runtime-member-string-references' -- | FileCheck %s -implicit-check-not="{{warning|error}}:" |
| 2 | |
| 3 | namespace std { |
| 4 | template<typename T> |
| 5 | class basic_string {}; |
| 6 | |
| 7 | typedef basic_string<char> string; |
| 8 | } |
| 9 | |
| 10 | class string {}; |
| 11 | |
| 12 | |
| 13 | struct A { |
| 14 | const std::string &s; |
| 15 | // CHECK: :[[@LINE-1]]:3: warning: const string& members are dangerous. It is much better to use alternatives, such as pointers or simple constants. |
| 16 | }; |
| 17 | |
| 18 | struct B { |
| 19 | std::string &s; |
| 20 | }; |
| 21 | |
| 22 | struct C { |
| 23 | const std::string s; |
| 24 | }; |
| 25 | |
| 26 | template <typename T> |
| 27 | struct D { |
| 28 | D(); |
| 29 | const T &s; |
| 30 | const std::string &s2; |
| 31 | // CHECK: :[[@LINE-1]]:3: warning: const string& members are dangerous. It is much better to use alternatives, such as pointers or simple constants. |
| 32 | }; |
| 33 | |
| 34 | D<std::string> d; |
| 35 | |
| 36 | struct AA { |
| 37 | const string &s; |
| 38 | // CHECK: :[[@LINE-1]]:3: warning: const string& members are dangerous. It is much better to use alternatives, such as pointers or simple constants. |
| 39 | }; |
| 40 | |
| 41 | struct BB { |
| 42 | string &s; |
| 43 | }; |
| 44 | |
| 45 | struct CC { |
| 46 | const string s; |
| 47 | }; |
| 48 | |
| 49 | D<string> dd; |