blob: 1536badad01bc4ca8ad683a42796841eee55df9a [file] [log] [blame]
Benjamin Kramerb1039752014-07-16 10:00:14 +00001// RUN: clang-tidy %s -checks='-*,google-runtime-member-string-references' -- | FileCheck %s -implicit-check-not="{{warning|error}}:"
2
3namespace std {
4template<typename T>
5 class basic_string {};
6
7typedef basic_string<char> string;
8}
9
10class string {};
11
12
13struct 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
18struct B {
19 std::string &s;
20};
21
22struct C {
23 const std::string s;
24};
25
26template <typename T>
27struct 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
34D<std::string> d;
35
36struct 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
41struct BB {
42 string &s;
43};
44
45struct CC {
46 const string s;
47};
48
49D<string> dd;