Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ void InitVariablesCheck::check(const MatchFinder::MatchResult &Result) {
<< MatchedDecl;
if (*InitializationString != nullptr)
Diagnostic << FixItHint::CreateInsertion(
utils::lexer::findNextTerminator(MatchedDecl->getLocation(),
utils::lexer::findNextTerminator(MatchedDecl->getEndLoc(),
*Result.SourceManager,
Result.Context->getLangOpts()),
*InitializationString);
Expand Down
4 changes: 4 additions & 0 deletions clang-tools-extra/docs/ReleaseNotes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,10 @@ Changes in existing checks
an additional matcher that generalizes the copy-and-swap idiom pattern
detection.

- Improved :doc:`cppcoreguidelines-init-variables
<clang-tidy/checks/cppcoreguidelines/init-variables>` check by fixing the
insertion location for function pointers with multiple parameters.

- Improved :doc:`cppcoreguidelines-prefer-member-initializer
<clang-tidy/checks/cppcoreguidelines/prefer-member-initializer>` check to
avoid false positives on inherited members in class templates.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,3 +148,23 @@ namespace gh112089 {
}
} // namespace gh112089

namespace gh161978 {
void test() {
bool (*fp1)(int);
// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: variable 'fp1' is not initialized [cppcoreguidelines-init-variables]
// CHECK-FIXES: bool (*fp1)(int) = nullptr;
bool (*fp2)(int, int);
// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: variable 'fp2' is not initialized [cppcoreguidelines-init-variables]
// CHECK-FIXES: bool (*fp2)(int, int) = nullptr;
bool (*fp3)(int, int, int);
// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: variable 'fp3' is not initialized [cppcoreguidelines-init-variables]
// CHECK-FIXES: bool (*fp3)(int, int, int) = nullptr;
bool (*fp4)(int, int, int, ...);
// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: variable 'fp4' is not initialized [cppcoreguidelines-init-variables]
// CHECK-FIXES: bool (*fp4)(int, int, int, ...) = nullptr;
bool (*fp5)(int, int), (*fp6)(int, int);
// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: variable 'fp5' is not initialized [cppcoreguidelines-init-variables]
// CHECK-MESSAGES: :[[@LINE-2]]:30: warning: variable 'fp6' is not initialized [cppcoreguidelines-init-variables]
// CHECK-FIXES: bool (*fp5)(int, int) = nullptr, (*fp6)(int, int) = nullptr;
}
}
Loading