[clang-tools-extra] [clang-tidy] Treat fields in anonymous records as names in enclosing scope when checking name styles (PR #75701)

Piotr Zegar via cfe-commits cfe-commits at lists.llvm.org
Tue Dec 26 02:59:14 PST 2023


================
@@ -207,6 +208,31 @@ After if AggressiveDependentMemberLookup is `true`:
       }
     };
 
+.. option:: CheckAnonFieldInParent
+
+    When set to `true`, fields in anonymous records (i.e. anonymous
+    unions and structs) will be treated as names in the enclosing scope
+    rather than public members of the anonymous record for the purpose
+    of name checking.
+
+For example:
+
+.. code-block:: c++
+
+    class Foo {
+    private:
+      union {
+        int iv_;
+        float fv_;
+      };
+    };
+
+If CheckAnonFieldInParent is `false`, you may get warnings that ``iv_`` and
+``fv_`` are not coherent to public member names, because ``iv_`` and ``fv_``
+are public members of the anonymous union. When CheckAnonFieldInParent is
----------------
PiotrZSL wrote:

:option:`CheckAnonFieldInParent`

https://github.com/llvm/llvm-project/pull/75701


More information about the cfe-commits mailing list