-
Notifications
You must be signed in to change notification settings - Fork 484
Add minimal binary pattern support for null checks in DFA #6877
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
Conversation
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## main #6877 +/- ##
==========================================
- Coverage 96.39% 96.39% -0.01%
==========================================
Files 1403 1403
Lines 330977 331075 +98
Branches 10890 10900 +10
==========================================
+ Hits 319055 319148 +93
- Misses 9188 9191 +3
- Partials 2734 2736 +2 |
0212991
to
b1d9dc2
Compare
@@ -1612,6 +1612,25 @@ private void PerformPredicateAnalysisCore(IOperation operation, TAnalysisData ta | |||
case OperationKind.BinaryPattern: | |||
// These high level patterns should not be present in the lowered CFG: https://github.com/dotnet/roslyn/issues/47068 | |||
predicateValueKind = PredicateValueKind.Unknown; | |||
|
|||
// We special case common null check to reduce false positives. But this implementation for BinaryPattern is very incomplete. | |||
if (FlowBranchConditionKind == ControlFlowConditionKind.WhenFalse) |
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.
This is a nice optimization! Generic flow analysis handling for binary pattern operations is going to be non-trivial as there are sort of conditional branches with the and
and or
operators. I think this is a good starting point to handle the most important cases.
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.
Thanks @Youssef1313!
Fixes #6755
@mavasani I have added very very minimal handling for binary patterns.
This doesn't handle declaration patterns, etc etc.
I can try to go further with the implementation whenever I get time again :)
I know my implementation might not be good enough. So, feel free if you wanted to close this PR and have a completely different fix.