Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bugprone-unchecked-optional-access does something even if no optional implementation is available #58097

Open
firewave opened this issue Oct 1, 2022 · 3 comments

Comments

@firewave
Copy link

firewave commented Oct 1, 2022

#57527 (comment) indicates that bugprone-unchecked-optional-access is in the upper third in terms of heaviness. This applies even if your are not using optional at all since you require either C++17 (std), the abseil library (absl::) or (apparently) the chromium project (base::).

It should be smarter about this and not do anything if these objects are not available.

The list of the objects to be checked should probably be configurable as well allowing additional optional implementations to be supported. It doesn't support Boost.Optional or llvm::Optional which is a bit strange as those are probably more wide-spread than the currently supported custom implementations.

This configuration could also offer another way to mitigate this issue by supporting an empty list essentially disabling the check.

@firewave
Copy link
Author

firewave commented Oct 1, 2022

Some comments on this from the original ticket: #57527 (comment).

@llvmbot
Copy link
Member

llvmbot commented Oct 1, 2022

@llvm/issue-subscribers-clang-tidy

@firewave
Copy link
Author

The check is not that heavy but it isn't free either (the *-identifiers checks are still up there as I am still using LLVM 16 on this system):

   ---User Time---   --System Time--   --User+System--   ---Wall Time---  --- Name ---
   1.3305 ( 28.0%)   0.5332 ( 23.2%)   1.8638 ( 26.4%)   1.8645 ( 26.4%)  misc-confusable-identifiers
   0.5771 ( 12.1%)   0.1803 (  7.8%)   0.7574 ( 10.7%)   0.7491 ( 10.6%)  bugprone-reserved-identifier
   0.2187 (  4.6%)   0.0361 (  1.6%)   0.2548 (  3.6%)   0.2549 (  3.6%)  modernize-use-using
[...]
   0.0624 (  1.3%)   0.0343 (  1.5%)   0.0967 (  1.4%)   0.0971 (  1.4%)  bugprone-unchecked-optional-access

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants