From b74b4fec46c871c5981422a7779fdf39c215487c Mon Sep 17 00:00:00 2001 From: Keith Smiley Date: Sat, 12 Oct 2024 13:38:36 -0700 Subject: [PATCH 1/4] [clang-tidy][readability-identifier-naming] Support namespace aliases Fixes: https://github.com/llvm/llvm-project/issues/109385 --- .../clang-tidy/readability/IdentifierNamingCheck.cpp | 3 +++ .../clang-tidy/checkers/readability/identifier-naming.cpp | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp b/clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp index 828f13805a69802..3f63eec2c51a8c3 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(D) && NamingStyles[SK_TypeAlias]) return SK_TypeAlias; + if (isa(D) && NamingStyles[SK_Namespace]) + return SK_Namespace; + if (const auto *Decl = dyn_cast(D)) { if (Decl->isAnonymousNamespace()) return SK_Invalid; 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 99149fe86aceecf..be5ba54513c672e 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 From ca2c8fedbe72d574bbd8ad2a10777e583efdc2b7 Mon Sep 17 00:00:00 2001 From: Keith Smiley Date: Mon, 14 Oct 2024 09:32:12 -0700 Subject: [PATCH 2/4] doc --- clang-tools-extra/docs/ReleaseNotes.rst | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/clang-tools-extra/docs/ReleaseNotes.rst b/clang-tools-extra/docs/ReleaseNotes.rst index 8655331dfc00e4e..ed0b6fbc04b89ef 100644 --- a/clang-tools-extra/docs/ReleaseNotes.rst +++ b/clang-tools-extra/docs/ReleaseNotes.rst @@ -242,6 +242,10 @@ Changes in existing checks ` check to remove `->`, when redundant `get()` is removed. +- Improved :doc:`readability-readability-identifier-naming + ` check support + ``namespace`` aliases. + Removed checks ^^^^^^^^^^^^^^ From 35598de698378662d04a36527d50d19fe536a294 Mon Sep 17 00:00:00 2001 From: Keith Smiley Date: Mon, 14 Oct 2024 09:32:56 -0700 Subject: [PATCH 3/4] dup --- clang-tools-extra/docs/ReleaseNotes.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clang-tools-extra/docs/ReleaseNotes.rst b/clang-tools-extra/docs/ReleaseNotes.rst index ed0b6fbc04b89ef..cb7348b1e50d478 100644 --- a/clang-tools-extra/docs/ReleaseNotes.rst +++ b/clang-tools-extra/docs/ReleaseNotes.rst @@ -242,7 +242,7 @@ Changes in existing checks ` check to remove `->`, when redundant `get()` is removed. -- Improved :doc:`readability-readability-identifier-naming +- Improved :doc:`readability-identifier-naming ` check support ``namespace`` aliases. From db17c915ac7d892b7acbeff07c20207b50d508db Mon Sep 17 00:00:00 2001 From: Keith Smiley Date: Mon, 14 Oct 2024 09:34:58 -0700 Subject: [PATCH 4/4] reword --- clang-tools-extra/docs/ReleaseNotes.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/clang-tools-extra/docs/ReleaseNotes.rst b/clang-tools-extra/docs/ReleaseNotes.rst index cb7348b1e50d478..29581249926b61a 100644 --- a/clang-tools-extra/docs/ReleaseNotes.rst +++ b/clang-tools-extra/docs/ReleaseNotes.rst @@ -243,8 +243,8 @@ Changes in existing checks remove `->`, when redundant `get()` is removed. - Improved :doc:`readability-identifier-naming - ` check support - ``namespace`` aliases. + ` check to + validate ``namespace`` aliases. Removed checks ^^^^^^^^^^^^^^