Skip to content

[clang-tidy] Rename out-of-line function definitions #91954

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 21, 2024
Merged
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
3 changes: 3 additions & 0 deletions clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,9 @@ static const NamedDecl *getFailureForNamedDecl(const NamedDecl *ND) {
if (const auto *Method = dyn_cast<CXXMethodDecl>(ND)) {
if (const CXXMethodDecl *Overridden = getOverrideMethod(Method))
Canonical = cast<NamedDecl>(Overridden->getCanonicalDecl());
else if (const FunctionTemplateDecl *Primary = Method->getPrimaryTemplate())
if (const FunctionDecl *TemplatedDecl = Primary->getTemplatedDecl())
Canonical = cast<NamedDecl>(TemplatedDecl->getCanonicalDecl());

if (Canonical != ND)
return Canonical;
Expand Down
3 changes: 2 additions & 1 deletion clang-tools-extra/docs/ReleaseNotes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,8 @@ Changes in existing checks
<clang-tidy/checks/readability/identifier-naming>` check in `GetConfigPerFile`
mode by resolving symbolic links to header files. Fixed handling of Hungarian
Prefix when configured to `LowerCase`. Added support for renaming designated
initializers. Added support for renaming macro arguments.
initializers. Added support for renaming macro arguments. Fixed renaming
conflicts arising from out-of-line member function template definitions.

- Improved :doc:`readability-implicit-bool-conversion
<clang-tidy/checks/readability/implicit-bool-conversion>` check to provide
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// RUN: %check_clang_tidy %s readability-identifier-naming %t -std=c++20 \
// RUN: --config='{CheckOptions: { \
// RUN: readability-identifier-naming.MethodCase: CamelCase, \
// RUN: }}'

namespace SomeNamespace {
namespace Inner {

class SomeClass {
public:
template <typename T>
int someMethod();
// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: invalid case style for method 'someMethod' [readability-identifier-naming]
// CHECK-FIXES: {{^}} int SomeMethod();
};
template <typename T>
int SomeClass::someMethod() {
// CHECK-FIXES: {{^}}int SomeClass::SomeMethod() {
return 5;
}

} // namespace Inner

void someFunc() {
Inner::SomeClass S;
S.someMethod<int>();
// CHECK-FIXES: {{^}} S.SomeMethod<int>();
}

} // namespace SomeNamespace
Loading