Issue 178114
Summary clang-tidy performance-enum-size check should ignore enums within extern "C"
Labels clang-tidy
Assignees
Reporter ptomato
    **bug.h**:
```c
#pragma once
extern "C" {
typedef enum { A, B } MyEnum;
}
```
To reproduce:
```
clang-tidy --checks=performance-enum-size --config='{CheckOptions:{"performance-enum-size.EnumIgnoreList": "MyEnum"}}' bug.h -- -xc++
```
Actual result:
> enum 'MyEnum' uses a larger base type ('unsigned int', size: 4 bytes) than necessary for its value set, consider using 'std::uint8_t' (1 byte) as the base type to reduce its size [performance-enum-size]

In addition, the ignore list is disregarded when the name is a typedef.

Expected result:
- Before C23, enums in C code can't have a base type, so the check warning can't be acted on and shouldn't be emitted.
- The error message knows the name of the enum despite it being a typedef, so the ignore list should be applied.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to