Page MenuHomePhabricator

janosbenjaminantal (János Benjamin Antal)
User

Projects

User does not belong to any projects.

User Details

User Since
Aug 9 2020, 8:10 AM (16 w, 13 h)

Recent Activity

Oct 21 2020

janosbenjaminantal added inline comments to D85697: [clang-tidy] Add cppcoreguidelines-prefer-scoped-enums.
Oct 21 2020, 11:42 PM · Restricted Project, Restricted Project
janosbenjaminantal added inline comments to D85697: [clang-tidy] Add cppcoreguidelines-prefer-scoped-enums.
Oct 21 2020, 11:39 PM · Restricted Project, Restricted Project

Oct 19 2020

janosbenjaminantal added a comment to D85697: [clang-tidy] Add cppcoreguidelines-prefer-scoped-enums.

I tend to be very skeptical of the value of checks that basically throw out entire usable chunks of the base language because the check is effectively impossible to apply to an existing code base. Have you run the check over large C++ code bases to see just how often the diagnostic triggers and whether there are ways we might want to reduce false-positives that the C++ Core Guidelines haven't considered as part of their enforcement strategy?

No, I haven't checked over large C++ code bases, but I will do this.

Btw, one fear I have with this check is that the automated fixits are somewhat risky -- unscoped vs scoped enumerations has ABI implications and changing from one to the other may break the ABI.

I am not familiar with these specific ABI implications, if you could help me with some keywords/references/link to start to investigate, I am happy to deep dive into it. I am also willing to discard the automated fixes if it makes this review better. What do you think?

Oct 19 2020, 4:47 PM · Restricted Project, Restricted Project
janosbenjaminantal added a comment to D85697: [clang-tidy] Add cppcoreguidelines-prefer-scoped-enums.

The known "limitations" are mostly similar to other checks:

  • It cannot detect unfixable cases from other translation units. Practically that means if an enum is used in multiple source files, one of them might end up not fixed. I tried to work around this, but I haven't found any solution for this, moreover this cause problems for other checks also. Therefore I think it shouldn't be a blocking issue.

That's what the run_clang_tidy.py script is meant to handle.

It is good to know, so it is not an issue.

  • It doesn't take into account if an enum is defined in a header that is filtered out. Similarly to the previous one, I tried to find a solution for this, but I was unable (the ClangTidyCheck class can access the header filter information, but it doesn't expose it for the descendant classes). I also checked other checks, and they behave in the same way. Therefore I also think it is shouldn't be a blocking issue.

I recently pushed an upgrade to readability-identifier-naming where it would check the naming style for identifiers declared in header files, maybe thats something this could also use, this is the commit 4888c9ce97d8

Will check.

It is not strongly connected to this review, but in the future I am planning to extend the check with:

  • options to exclude enums, because changing them to scoped enumerations might not be suitable for every cases

Not strictly necessary, if people don't want the fix they could annotate the code with a // NOLINT(*prefer-unscoped-enums) comment.

I think with the inline suppression the users should annotate every usage of the enum while with the option it would be enough to list the enum's name to ignore it from the whole check. However it is just an improvement, when I reach that point I will do further digging about this topic, how the suppression actually work etc.

  • options to force the doable fixes: based on my little experience it might be easier to force the doable fixes and manually fix the remaining ones

Forcing the fix is usually just a case of converting implicit cast usages of the constants into static casts.

What I meant is an option to express that the user don't care if there are some cases for an enum that cannot be fixed: fixed the other occurrences and the user will handle the rest. Currently the automated fix only fix the enums where every occurrence can be fixed. As a second thought this might be superfluous, because the other way is always possible: the user first fix the occurrences that cannot be fixed automatically and then use the check to fix the rest. So I think it is something that wouldn't mean real value.

Oct 19 2020, 4:13 PM · Restricted Project, Restricted Project

Aug 24 2020

janosbenjaminantal updated the diff for D85697: [clang-tidy] Add cppcoreguidelines-prefer-scoped-enums.

Fix clang-tidy issues.

Aug 24 2020, 1:05 PM · Restricted Project, Restricted Project
janosbenjaminantal updated the diff for D85697: [clang-tidy] Add cppcoreguidelines-prefer-scoped-enums.
Aug 24 2020, 12:40 PM · Restricted Project, Restricted Project
janosbenjaminantal added a comment to D85697: [clang-tidy] Add cppcoreguidelines-prefer-scoped-enums.

I addressed all of the review comments. Apart from the small fixes I extended a checker logic.

Aug 24 2020, 12:40 PM · Restricted Project, Restricted Project

Aug 11 2020

janosbenjaminantal added a comment to D85697: [clang-tidy] Add cppcoreguidelines-prefer-scoped-enums.

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.

Aug 11 2020, 3:28 AM · Restricted Project, Restricted Project

Aug 10 2020

janosbenjaminantal requested review of D85697: [clang-tidy] Add cppcoreguidelines-prefer-scoped-enums.
Aug 10 2020, 5:08 PM · Restricted Project, Restricted Project