File tree Expand file tree Collapse file tree 3 files changed +21
-1
lines changed Expand file tree Collapse file tree 3 files changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -108,7 +108,7 @@ void InitVariablesCheck::check(const MatchFinder::MatchResult &Result) {
108
108
<< MatchedDecl;
109
109
if (*InitializationString != nullptr )
110
110
Diagnostic << FixItHint::CreateInsertion (
111
- utils::lexer::findNextTerminator (MatchedDecl->getLocation (),
111
+ utils::lexer::findNextTerminator (MatchedDecl->getEndLoc (),
112
112
*Result.SourceManager ,
113
113
Result.Context ->getLangOpts ()),
114
114
*InitializationString);
Original file line number Diff line number Diff line change @@ -299,6 +299,10 @@ Changes in existing checks
299
299
an additional matcher that generalizes the copy-and-swap idiom pattern
300
300
detection.
301
301
302
+ - Improved :doc: `cppcoreguidelines-init-variables
303
+ <clang-tidy/checks/cppcoreguidelines/init-variables>` check by fixing the
304
+ insertion location for function pointers with multiple parameters.
305
+
302
306
- Improved :doc: `cppcoreguidelines-prefer-member-initializer
303
307
<clang-tidy/checks/cppcoreguidelines/prefer-member-initializer>` check to
304
308
avoid false positives on inherited members in class templates.
Original file line number Diff line number Diff line change @@ -148,3 +148,19 @@ namespace gh112089 {
148
148
}
149
149
} // namespace gh112089
150
150
151
+ namespace gh161978 {
152
+ void test () {
153
+ bool (*fp1)(int );
154
+ // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: variable 'fp1' is not initialized [cppcoreguidelines-init-variables]
155
+ // CHECK-FIXES: bool (*fp1)(int) = nullptr;
156
+ bool (*fp2)(int , int );
157
+ // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: variable 'fp2' is not initialized [cppcoreguidelines-init-variables]
158
+ // CHECK-FIXES: bool (*fp2)(int, int) = nullptr;
159
+ bool (*fp3)(int , int , int );
160
+ // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: variable 'fp3' is not initialized [cppcoreguidelines-init-variables]
161
+ // CHECK-FIXES: bool (*fp3)(int, int, int) = nullptr;
162
+ bool (*fp4)(int , int , int , ...);
163
+ // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: variable 'fp4' is not initialized [cppcoreguidelines-init-variables]
164
+ // CHECK-FIXES: bool (*fp4)(int, int, int, ...) = nullptr;
165
+ }
166
+ }
You can’t perform that action at this time.
0 commit comments