[clang-tools-extra] c79e5ac - [clang-tidy][readability-identifier-naming] Support namespace aliases (#112112)
via cfe-commits
cfe-commits at lists.llvm.org
Mon Oct 14 09:35:24 PDT 2024
Author: Keith Smiley
Date: 2024-10-14T09:35:20-07:00
New Revision: c79e5acfe8d4bb01d5ae7297dcb900ad8c39c580
URL: https://github.com/llvm/llvm-project/commit/c79e5acfe8d4bb01d5ae7297dcb900ad8c39c580
DIFF: https://github.com/llvm/llvm-project/commit/c79e5acfe8d4bb01d5ae7297dcb900ad8c39c580.diff
LOG: [clang-tidy][readability-identifier-naming] Support namespace aliases (#112112)
Fixes: https://github.com/llvm/llvm-project/issues/109385
Added:
Modified:
clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
clang-tools-extra/docs/ReleaseNotes.rst
clang-tools-extra/test/clang-tidy/checkers/readability/identifier-naming.cpp
Removed:
################################################################################
diff --git a/clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp b/clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
index 828f13805a6980..3f63eec2c51a8c 100644
--- a/clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
@@ -1135,6 +1135,9 @@ StyleKind IdentifierNamingCheck::findStyleKind(
if (isa<TypeAliasDecl>(D) && NamingStyles[SK_TypeAlias])
return SK_TypeAlias;
+ if (isa<NamespaceAliasDecl>(D) && NamingStyles[SK_Namespace])
+ return SK_Namespace;
+
if (const auto *Decl = dyn_cast<NamespaceDecl>(D)) {
if (Decl->isAnonymousNamespace())
return SK_Invalid;
diff --git a/clang-tools-extra/docs/ReleaseNotes.rst b/clang-tools-extra/docs/ReleaseNotes.rst
index 39b600f361e8c5..b07211ff1bcaab 100644
--- a/clang-tools-extra/docs/ReleaseNotes.rst
+++ b/clang-tools-extra/docs/ReleaseNotes.rst
@@ -244,6 +244,10 @@ Changes in existing checks
<clang-tidy/checks/readability/redundant-smartptr-get>` check to
remove `->`, when redundant `get()` is removed.
+- Improved :doc:`readability-identifier-naming
+ <clang-tidy/checks/readability/readability-identifier-naming>` check to
+ validate ``namespace`` aliases.
+
Removed checks
^^^^^^^^^^^^^^
diff --git a/clang-tools-extra/test/clang-tidy/checkers/readability/identifier-naming.cpp b/clang-tools-extra/test/clang-tidy/checkers/readability/identifier-naming.cpp
index 99149fe86aceec..be5ba54513c672 100644
--- a/clang-tools-extra/test/clang-tidy/checkers/readability/identifier-naming.cpp
+++ b/clang-tools-extra/test/clang-tidy/checkers/readability/identifier-naming.cpp
@@ -101,6 +101,10 @@ inline namespace InlineNamespace {
// CHECK-MESSAGES: :[[@LINE-1]]:18: warning: invalid case style for inline namespace 'InlineNamespace'
// CHECK-FIXES: {{^}}inline namespace inline_namespace {{{$}}
+namespace FOO_ALIAS = FOO_NS;
+// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: invalid case style for namespace 'FOO_ALIAS' [readability-identifier-naming]
+// CHECK-FIXES: {{^}}namespace foo_alias = FOO_NS;{{$}}
+
SYSTEM_NS::structure g_s1;
// NO warnings or fixes expected as SYSTEM_NS and structure are declared in a header file
More information about the cfe-commits
mailing list