Author: Zeyi Xu Date: 2026-09-12T12:28:51+08:00 New Revision: 070455b3f2f77dbd1d5121a9d1bc3d9a3e3f65bc
URL: https://github.com/llvm/llvm-project/commit/070455b3f2f77dbd1d5121a9d1bc3d9a3e3f65bc DIFF: https://github.com/llvm/llvm-project/commit/070455b3f2f77dbd1d5121a9d1bc3d9a3e3f65bc.diff LOG: [clang-tidy] Fix convert-member-functions-to-static crash on attributed methods (#223007) Fixes #222951 Added: Modified: clang-tools-extra/clang-tidy/readability/ConvertMemberFunctionsToStaticCheck.cpp clang-tools-extra/docs/ReleaseNotes.md clang-tools-extra/test/clang-tidy/checkers/readability/convert-member-functions-to-static.cpp Removed: ################################################################################ diff --git a/clang-tools-extra/clang-tidy/readability/ConvertMemberFunctionsToStaticCheck.cpp b/clang-tools-extra/clang-tidy/readability/ConvertMemberFunctionsToStaticCheck.cpp index 62c786abaf174..1671743db2186 100644 --- a/clang-tools-extra/clang-tidy/readability/ConvertMemberFunctionsToStaticCheck.cpp +++ b/clang-tools-extra/clang-tidy/readability/ConvertMemberFunctionsToStaticCheck.cpp @@ -148,7 +148,7 @@ static SourceRange getLocationOfConst(const TypeSourceInfo *TSI, const SourceManager &SourceMgr, const LangOptions &LangOpts) { assert(TSI); - const auto FTL = TSI->getTypeLoc().IgnoreParens().getAs<FunctionTypeLoc>(); + const auto FTL = TSI->getTypeLoc().getAsAdjusted<FunctionTypeLoc>(); assert(FTL); const SourceRange Range{FTL.getRParenLoc().getLocWithOffset(1), diff --git a/clang-tools-extra/docs/ReleaseNotes.md b/clang-tools-extra/docs/ReleaseNotes.md index 6fff0359afd91..98105ac222df9 100644 --- a/clang-tools-extra/docs/ReleaseNotes.md +++ b/clang-tools-extra/docs/ReleaseNotes.md @@ -224,6 +224,11 @@ infrastructure are described first, followed by tool-specific sections. offered when an argument covers only part of a macro expansion, as it then has no source text of its own. +- Improved {doc}`readability-convert-member-functions-to-static + <clang-tidy/checks/readability/convert-member-functions-to-static>` check by + fixing a crash when checking a const-qualified method declared with the + `lifetimebound` attribute. + - Improved {doc}`readability-enum-initial-value <clang-tidy/checks/readability/enum-initial-value>` check by adding the {option}`AllowReferencedInitialValues` to support the diff --git a/clang-tools-extra/test/clang-tidy/checkers/readability/convert-member-functions-to-static.cpp b/clang-tools-extra/test/clang-tidy/checkers/readability/convert-member-functions-to-static.cpp index 013d1ee7ddf10..c788b91511e74 100644 --- a/clang-tools-extra/test/clang-tidy/checkers/readability/convert-member-functions-to-static.cpp +++ b/clang-tools-extra/test/clang-tidy/checkers/readability/convert-member-functions-to-static.cpp @@ -74,6 +74,12 @@ class A { return static_field; } + int lifetime_bound() const [[clang::lifetimebound]] { + // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: method 'lifetime_bound' can be made static + // CHECK-FIXES: static int lifetime_bound() {{\[\[}}clang::lifetimebound{{\]\]}} { + return static_field; + } + static int out_of_line_already_static(); void out_of_line_call_static(); _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
