llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
29.03k stars 11.96k forks source link

clang-tidy: Reduce modernize-use-using diagnostic range for typedef enums #62702

Open arijun opened 1 year ago

arijun commented 1 year ago

When someone defines a C-style enum with typdef enum {...} name, the entirety of the enum (from typedef to name) is highlighted by modernize-use-using. This can be a bit jarring in longer enums where there can be hundreds of lines of enum entries marked with a warning. It also doesn't seem to be in line with the rest of the modernize- lints; in modernize-avoid-c-arrays, int arr[3] would only highlight the int and not everything through the [3], and modernize-loop-convert similarly only highlights the for.

This issue is made worse in the VS Code clangd extension, where modernize- lints are marked as deprecated, and are struck-through in addition to being highlighted--greatly reducing readability of the enum entries. For example image

llvmbot commented 1 year ago

@llvm/issue-subscribers-clang-tidy

HighCommander4 commented 1 year ago

I think it would make sense to limit the diagnostic range to the typedef keyword for all modernize-use-using diagnostics (not just ones for enums).

PiotrZSL commented 1 year ago

This isn't a highlight, that is a "fix":

1.cpp:1:1: warning: use 'using' instead of 'typedef' [modernize-use-using]
    1 | typedef enum {A, B, C} myEnum;
      | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      | using myEnum = enum {A, B, C}