Skip to content

Commit c79e5ac

Browse files
authored
[clang-tidy][readability-identifier-naming] Support namespace aliases (#112112)
Fixes: #109385
1 parent 39ac8b2 commit c79e5ac

File tree

3 files changed

+11
-0
lines changed

3 files changed

+11
-0
lines changed

clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1135,6 +1135,9 @@ StyleKind IdentifierNamingCheck::findStyleKind(
11351135
if (isa<TypeAliasDecl>(D) && NamingStyles[SK_TypeAlias])
11361136
return SK_TypeAlias;
11371137

1138+
if (isa<NamespaceAliasDecl>(D) && NamingStyles[SK_Namespace])
1139+
return SK_Namespace;
1140+
11381141
if (const auto *Decl = dyn_cast<NamespaceDecl>(D)) {
11391142
if (Decl->isAnonymousNamespace())
11401143
return SK_Invalid;

clang-tools-extra/docs/ReleaseNotes.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,10 @@ Changes in existing checks
244244
<clang-tidy/checks/readability/redundant-smartptr-get>` check to
245245
remove `->`, when redundant `get()` is removed.
246246

247+
- Improved :doc:`readability-identifier-naming
248+
<clang-tidy/checks/readability/readability-identifier-naming>` check to
249+
validate ``namespace`` aliases.
250+
247251
Removed checks
248252
^^^^^^^^^^^^^^
249253

clang-tools-extra/test/clang-tidy/checkers/readability/identifier-naming.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,10 @@ inline namespace InlineNamespace {
101101
// CHECK-MESSAGES: :[[@LINE-1]]:18: warning: invalid case style for inline namespace 'InlineNamespace'
102102
// CHECK-FIXES: {{^}}inline namespace inline_namespace {{{$}}
103103

104+
namespace FOO_ALIAS = FOO_NS;
105+
// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: invalid case style for namespace 'FOO_ALIAS' [readability-identifier-naming]
106+
// CHECK-FIXES: {{^}}namespace foo_alias = FOO_NS;{{$}}
107+
104108
SYSTEM_NS::structure g_s1;
105109
// NO warnings or fixes expected as SYSTEM_NS and structure are declared in a header file
106110

0 commit comments

Comments
 (0)