From 31ded495271e5869d619da851a351c9f6f05b2d4 Mon Sep 17 00:00:00 2001 From: Congcong Cai Date: Thu, 7 Sep 2023 17:06:28 +0800 Subject: [clang-tidy][modernize-use-using]fix function pointer typedef correctly (#65558) Fixed #65055 For normal type, typedef is from typedef to the end of original type, but for function pointer it is from typedef to the end. So it needs to consider alias name length for normal type. --- clang-tools-extra/clang-tidy/modernize/UseUsingCheck.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'clang-tools-extra/clang-tidy/modernize/UseUsingCheck.cpp') diff --git a/clang-tools-extra/clang-tidy/modernize/UseUsingCheck.cpp b/clang-tools-extra/clang-tidy/modernize/UseUsingCheck.cpp index c1af8b5..22dc9e2 100644 --- a/clang-tools-extra/clang-tidy/modernize/UseUsingCheck.cpp +++ b/clang-tools-extra/clang-tidy/modernize/UseUsingCheck.cpp @@ -120,8 +120,10 @@ void UseUsingCheck::check(const MatchFinder::MatchResult &Result) { Type.substr(0, FirstTypedefType.size()) == FirstTypedefType) Type = FirstTypedefName + Type.substr(FirstTypedefType.size() + 1); } - if (!ReplaceRange.getEnd().isMacroID()) - LastReplacementEnd = ReplaceRange.getEnd().getLocWithOffset(Name.size()); + if (!ReplaceRange.getEnd().isMacroID()) { + const SourceLocation::IntTy Offset = MatchedDecl->getFunctionType() ? 0 : Name.size(); + LastReplacementEnd = ReplaceRange.getEnd().getLocWithOffset(Offset); + } auto Diag = diag(ReplaceRange.getBegin(), UseUsingWarning); -- cgit v1.1