[PATCH] D85697: [clang-tidy] Add cppcoreguidelines-prefer-scoped-enums-over-unscoped

János Benjamin Antal via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Aug 11 03:28:16 PDT 2020


janosbenjaminantal added a comment.

In D85697#2209272 <https://reviews.llvm.org/D85697#2209272>, @njames93 wrote:

> Is 'over-unscoped' really needed in the name, would just 'prefer-scoped-enum' be better, WDYT?
>
> For the case of macro, you can check if the location is a macro using `SourceLocation::isMacroID()`.
>
> For this to work you would also need to check every single usage of the the values in the enum to make sure they are converted to use the scoped access.
> You're best bet would be to actually store a map indexed by unscoped enum decls with a set of all their locations and maybe a flag to say if the fix can be applied or not.
> For instance a fix couldn't be applied if any of the usages or decls are in macros.
> This map could then be checked using the `endOfTranslationUnit` virtual method, with all the diags and fixes being spawned there.

Yes, it is better without 'over-unscoped'. I will change this.

I checked how other checks are dealing with macros, but I haven't found anything useful. Your idea sounds good, I will try to implement it.

- Fix not just the declarations, but also the enum usages
- Fix only the enums that are not declared/used in macros

As I am totally new to llvm, it might take a few days to come with a proper solutions, but I will do my best.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D85697/new/

https://reviews.llvm.org/D85697



More information about the cfe-commits mailing list