[clang-tools-extra] [clang-tidy] Add new check: `readability-redundant-typename` (PR #161574)
Victor Chernyakin via cfe-commits
cfe-commits at lists.llvm.org
Wed Oct 1 13:48:34 PDT 2025
================
@@ -0,0 +1,26 @@
+.. title:: clang-tidy - readability-redundant-typename
+
+readability-redundant-typename
+==============================
+
+Finds unnecessary uses of the ``typename`` keyword.
+
+``typename`` is unnecessary in two cases. First, before non-dependent names:
+
+.. code-block:: c++
+
+ /* typename */ std::vector<int>::size_type size;
+
+And second, since C++20, before dependent names that appear in a context
+where only a type is allowed (the following example shows just a few of them):
+
+.. code-block:: c++
+
+ template <typename T>
+ using trait = /* typename */ T::type;
+
+ template <typename T>
+ struct S {
+ /* typename */ T::type variable;
+ /* typename */ T::type function(/* typename */ T::type);
+ };
----------------
localspook wrote:
I’m worried that adding *all* cases would make the documentation quite long for little benefit. Some of the cases are pretty esoteric too (for example: type of parameter in function with qualified name); would users be interested in that?
https://github.com/llvm/llvm-project/pull/161574
More information about the cfe-commits
mailing list