aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Target/AArch64/AArch64LoadStoreOptimizer.cpp
diff options
context:
space:
mode:
authortigbr <gabor.tothvari@ericsson.com>2025-08-03 11:33:29 +0000
committerGitHub <noreply@github.com>2025-08-03 14:33:29 +0300
commitb16fe132c68834a601b29c0eb53c7ec25a3cd627 (patch)
tree9e9689608bab58ef14f314d408b7ca0940a4d3e4 /llvm/lib/Target/AArch64/AArch64LoadStoreOptimizer.cpp
parent559d1dff891682ec66d4a987dfa0b9404c7af3e4 (diff)
downloadllvm-main.zip
llvm-main.tar.gz
llvm-main.tar.bz2
[clang-tidy] Fix bugprone-tagged-union-member-count false-positive (#135831)HEADmain
This patch implements a fix for the false-positive case described in [issue #134840](https://github.com/llvm/llvm-project/issues/134840) for the [bugprone-tagged-union-member-count](https://clang.llvm.org/extra/clang-tidy/checks/bugprone/tagged-union-member-count.html) clang-tidy check. The example given in the linked issue was the following: ```C #include <pthread.h> typedef enum { MYENUM_ONE, MYENUM_TWO, } myEnumT; typedef struct { pthread_mutex_t mtx; myEnumT my_enum; } myTypeT; ``` The [bugprone-tagged-union-member-count](https://clang.llvm.org/extra/clang-tidy/checks/bugprone/tagged-union-member-count.html) check emits the following a warning for this struct: ``` <source>:8:9: warning: tagged union has more data members (3) than tags (2)! [bugprone-tagged-union-member-count] 8 | typedef struct { | ^ 1 warning generated. ``` The issue is that `pthread_mutex_t` can be a union behind a typedef like the following: ```C typedef union { struct __pthread_mutex_s __data; char __size[__SIZEOF_PTHREAD_MUTEX_T]; long int __align; } pthread_mutex_t; ``` From the checker's point of view therefore `myTypeT` contains a data member with an enum type and another data member with a union type and starts analyzing it like a user-defined tagged union. The proposed solution is that the types from system headers and the std namespace are no longer candidates to be the enum part or the union part of a user-defined tagged union. This filtering for enums and the std namespace may not be strictly necessary in this example, however I added it preemptively out of (perhaps unnecessary) caution. Fixes https://github.com/llvm/llvm-project/issues/134840.
Diffstat (limited to 'llvm/lib/Target/AArch64/AArch64LoadStoreOptimizer.cpp')
0 files changed, 0 insertions, 0 deletions