János Benjamin Antal via llvm-dev
2020-Aug-18 12:21 UTC
[llvm-dev] Implementing clang-tidy check to prefer scoped enumerations
Hi, As my first contribution to LLVM I would like to implement a clang-tidy check that enforces the usage of scoped enumerations based on the C++ Core Guidelines <https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#Renum-class>. I already submitted a review <https://reviews.llvm.org/D85697#2209272> and now I am working on the changes based on the feedback. I think I addressed most of the feedback, but I have some difficulties to figure out when an unscoped enum cannot be changed to scoped enumerations. A good example for this is already mentioned in the review: when any of the decls or the usages (except the ones that are properly qualified by the enum name) are in a macro. I think another example for the unfixable case might be if any of the decls or the usages are in a source from where the diagnostics are emitted, i.e.: filtered out with header-filter or line-filter arguments. Can I somehow extract that information within a derived class of ClangTidyCheck? I think the ClangTidiyCheck::Context member variable holds that information, but it doesn't expose that member nor the necessary information to the derived classes. To sum up, my questions are: 1. Can I somehow check from a derived ClangTidyCheck if the current location is going to be filtered out? 2. If the answer for the previous question is no, then how should I handle this situation? 3. Do you know any other case where the decls/usages shouldn't be fixed? Thanks for the help, Benjamin -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20200818/5bed2b15/attachment.html>