Lines Matching full:auto
1 // RUN: %check_clang_tidy %s readability-qualified-auto %t
15 auto TdNakedPtr = getPtr(); in foo()
16 …// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 'auto TdNakedPtr' can be declared as 'auto *TdNakedPtr' in foo()
17 // CHECK-FIXES: {{^}} auto *TdNakedPtr = getPtr(); in foo()
18 auto &TdNakedRef = getRef(); in foo()
19 auto TdNakedRefDeref = getRef(); in foo()
20 auto TdNakedCPtr = getCPtr(); in foo()
21 …// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 'auto TdNakedCPtr' can be declared as 'const auto *TdN… in foo()
22 // CHECK-FIXES: {{^}} const auto *TdNakedCPtr = getCPtr(); in foo()
23 auto &TdNakedCRef = getCRef(); in foo()
24 …// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 'auto &TdNakedCRef' can be declared as 'const auto &Td… in foo()
25 // CHECK-FIXES: {{^}} const auto &TdNakedCRef = getCRef(); in foo()
26 auto TdNakedCRefDeref = getCRef(); in foo()
43 auto UNakedPtr = getPtr(); in foo()
44 // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 'auto UNakedPtr' can be declared as 'auto *UNakedPtr' in foo()
45 // CHECK-FIXES: {{^}} auto *UNakedPtr = getPtr(); in foo()
46 auto &UNakedRef = getRef(); in foo()
47 auto UNakedRefDeref = getRef(); in foo()
48 auto UNakedCPtr = getCPtr(); in foo()
49 …// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 'auto UNakedCPtr' can be declared as 'const auto *UNak… in foo()
50 // CHECK-FIXES: {{^}} const auto *UNakedCPtr = getCPtr(); in foo()
51 auto &UNakedCRef = getCRef(); in foo()
52 …// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 'auto &UNakedCRef' can be declared as 'const auto &UNa… in foo()
53 // CHECK-FIXES: {{^}} const auto &UNakedCRef = getCRef(); in foo()
54 auto UNakedCRefDeref = getCRef(); in foo()
71 // make sure check disregards auto types that aren't pointers or references in foo()
72 auto AutoInt = getInt(); in foo()
74 auto NakedPtr = getIntPtr(); in foo()
75 // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 'auto NakedPtr' can be declared as 'auto *NakedPtr' in foo()
76 // CHECK-FIXES: {{^}} auto *NakedPtr = getIntPtr(); in foo()
77 auto NakedCPtr = getCIntPtr(); in foo()
78 …// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 'auto NakedCPtr' can be declared as 'const auto *Naked… in foo()
79 // CHECK-FIXES: {{^}} const auto *NakedCPtr = getCIntPtr(); in foo()
81 const auto ConstPtr = getIntPtr(); in foo()
82 …// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 'const auto ConstPtr' can be declared as 'auto *const … in foo()
83 // CHECK-FIXES: {{^}} auto *const ConstPtr = getIntPtr(); in foo()
84 const auto ConstCPtr = getCIntPtr(); in foo()
85 …// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 'const auto ConstCPtr' can be declared as 'const auto … in foo()
86 // CHECK-FIXES: {{^}} const auto *const ConstCPtr = getCIntPtr(); in foo()
88 volatile auto VolatilePtr = getIntPtr(); in foo()
89 …// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 'volatile auto VolatilePtr' can be declared as 'auto *… in foo()
90 // CHECK-FIXES: {{^}} auto *volatile VolatilePtr = getIntPtr(); in foo()
91 volatile auto VolatileCPtr = getCIntPtr(); in foo()
92 … CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 'volatile auto VolatileCPtr' can be declared as 'const a… in foo()
93 // CHECK-FIXES: {{^}} const auto *volatile VolatileCPtr = getCIntPtr(); in foo()
95 auto *QualPtr = getIntPtr(); in foo()
96 auto *QualCPtr = getCIntPtr(); in foo()
97 …// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 'auto *QualCPtr' can be declared as 'const auto *QualC… in foo()
98 // CHECK-FIXES: {{^}} const auto *QualCPtr = getCIntPtr(); in foo()
99 auto *const ConstantQualCPtr = getCIntPtr(); in foo()
100 …// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 'auto *const ConstantQualCPtr' can be declared as 'con… in foo()
101 // CHECK-FIXES: {{^}} const auto *const ConstantQualCPtr = getCIntPtr(); in foo()
102 auto *volatile VolatileQualCPtr = getCIntPtr(); in foo()
103 …// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 'auto *volatile VolatileQualCPtr' can be declared as '… in foo()
104 // CHECK-FIXES: {{^}} const auto *volatile VolatileQualCPtr = getCIntPtr(); in foo()
105 const auto *ConstQualCPtr = getCIntPtr(); in foo()
107 auto &Ref = *getIntPtr(); in foo()
108 auto &CRef = *getCIntPtr(); in foo()
109 // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 'auto &CRef' can be declared as 'const auto &CRef' in foo()
110 // CHECK-FIXES: {{^}} const auto &CRef = *getCIntPtr(); in foo()
111 const auto &ConstCRef = *getCIntPtr(); in foo()
113 if (auto X = getCIntPtr()) { in foo()
114 // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: 'auto X' can be declared as 'const auto *X' in foo()
115 // CHECK-FIXES: {{^}} if (const auto *X = getCIntPtr()) { in foo()
120 #define _AUTO auto in macroTest()
125 _CONST auto ConstMacroAutoPtr = getIntPtr(); in macroTest()
147 for (auto &Data : Mutate) { in loopRef()
150 for (auto &Data : Constant) { in loopRef()
151 // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: 'auto &Data' can be declared as 'const auto &Data' in loopRef()
152 // CHECK-FIXES: {{^}} for (const auto &Data : Constant) { in loopRef()
158 for (auto Data : Mutate) { in loopPtr()
159 // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: 'auto Data' can be declared as 'auto *Data' in loopPtr()
160 // CHECK-FIXES: {{^}} for (auto *Data : Mutate) { in loopPtr()
163 for (auto Data : Constant) { in loopPtr()
164 // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: 'auto Data' can be declared as 'const auto *Data' in loopPtr()
165 // CHECK-FIXES: {{^}} for (const auto *Data : Constant) { in loopPtr()
172 for (auto Data : MutateTemplate) { in tempLoopPtr()
173 // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: 'auto Data' can be declared as 'auto *Data' in tempLoopPtr()
174 // CHECK-FIXES: {{^}} for (auto *Data : MutateTemplate) { in tempLoopPtr()
178 for (auto Data : ConstantTemplate) { in tempLoopPtr()
179 // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: 'auto Data' can be declared as 'const auto *Data' in tempLoopPtr()
180 // CHECK-FIXES: {{^}} for (const auto *Data : ConstantTemplate) { in tempLoopPtr()
189 for (auto Data : MClassTemplate) { in operator ()()
190 // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: 'auto Data' can be declared as 'auto *Data' in operator ()()
191 // CHECK-FIXES: {{^}} for (auto *Data : MClassTemplate) { in operator ()()
195 for (auto Data : CClassTemplate) { in operator ()()
196 // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: 'auto Data' can be declared as 'const auto *Data' in operator ()()
197 // CHECK-FIXES: {{^}} for (const auto *Data : CClassTemplate) { in operator ()()
220 auto MyFunctionPtr = getPtrFunction(); in baz()
221 …// CHECK-MESSAGES-NOT: :[[@LINE-1]]:3: warning: 'auto MyFunctionPtr' can be declared as 'auto *MyF… in baz()
222 // CHECK-FIXES-NOT: {{^}} auto *MyFunctionPtr = getPtrFunction(); in baz()
223 auto MyFunctionVal = getValFunction(); in baz()
224 …// CHECK-MESSAGES-NOT: :[[@LINE-1]]:3: warning: 'auto MyFunctionVal' can be declared as 'auto *MyF… in baz()
225 // CHECK-FIXES-NOT: {{^}} auto *MyFunctionVal = getValFunction(); in baz()
227 auto LambdaTest = [] { return 0; }; in baz()
228 …// CHECK-MESSAGES-NOT: :[[@LINE-1]]:3: warning: 'auto LambdaTest' can be declared as 'auto *Lambda… in baz()
229 // CHECK-FIXES-NOT: {{^}} auto *LambdaTest = [] { return 0; }; in baz()
231 auto LambdaTest2 = +[] { return 0; }; in baz()
232 …// CHECK-MESSAGES-NOT: :[[@LINE-1]]:3: warning: 'auto LambdaTest2' can be declared as 'auto *Lambd… in baz()
233 // CHECK-FIXES-NOT: {{^}} auto *LambdaTest2 = +[] { return 0; }; in baz()
235 auto MyFunctionRef = *getPtrFunction(); in baz()
236 …// CHECK-MESSAGES-NOT: :[[@LINE-1]]:3: warning: 'auto MyFunctionRef' can be declared as 'auto *MyF… in baz()
237 // CHECK-FIXES-NOT: {{^}} auto *MyFunctionRef = *getPtrFunction(); in baz()
239 auto &MyFunctionRef2 = *getPtrFunction(); in baz()