mirror of
https://github.com/intel/llvm.git
synced 2026-01-26 21:53:12 +08:00
[clang-tidy] Rename out-of-line function definitions (#91954)
Member function templates defined out-of-line were resulting in conflicting naming failures with overlapping usage sets. With this change, out-of-line definitions are treated as a usage of the failure which is the inline declaration.
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -375,7 +375,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
|
||||
|
||||
@@ -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
|
||||
Reference in New Issue
Block a user