-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[clang-tidy] bugprone-unchecked-optional-access
: handle BloombergLP::bdlb:NullableValue::makeValue
to prevent false-positives
#144313
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
Open
BaLiKfromUA
wants to merge
3
commits into
llvm:main
Choose a base branch
from
BaLiKfromUA-education:makeValue-false-positive
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+36
−0
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think configurable option is needed instead of hard code function name for non-std libarary.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@HerrCai0907 I am happy to do so! Are there any examples how it looks for other clang-tidy checks?
Also, do you want to do it in scope of this PR or as a separate one?
Since non-std function names (e.g.
hasValue
) are also processed forfolly::Optional
in code above my change.Thanks for review!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can look at no-malloc check for similar option with function names.
You can add function-lists both for
bdlb
and other libraries. The code must be very similar.Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@vbvictor, thank you for the help! I checked the implementation of
no-malloc
configuration, and it does make sense to me.Just want to double-check expectation, do we want to have a configuration like this, with just method names (name of options is subject to change):
Or do we want to specify which class method belongs to:
For me, the first version looks better because:
However, it's less intuitive to me than option two because different non-standard methods belong to different classes. But this is how it works now, so maybe we could build on top of it, just with method names, and then improve it or extend it.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd prefer 2nd option because we have more control over what method belong to what class. Imagine this situation:
If we go with 1st option, we would write
NonStdNoValue: hasNull;isNull
, but that would produce errors becauseoptional1::hasNull
doesn't actually check for no value,optional1::isNull
does.To express intentional behavior, we need to write
NonStdNoValue: optional2::hasNull;optional1::isNull
.Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But if it works like option1 right now, I don't oppose implementing option1.
I suppose we could harden it in the future if ever needed. My example with
optional1
andoptional2
wouldn't likely appear in real life IMO.