-
Notifications
You must be signed in to change notification settings - Fork 485
Perform exceptions path analysis for all flow analyses #6828
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
Perform exceptions path analysis for all flow analyses #6828
Conversation
Fixes dotnet#5199 Fixes dotnet#5160 We already had implementation and option based support to perform exception path analysis to handle all operations that can potentially throw an exception, and hence need flow analysis data at the point of operation to be merged with analysis data at start of reachable catch blocks from that operation. However, we were only performing this analysis post pass when flow analysis is looking at exceptions data. Now we do it for all analysis as this is required for more accurate input analysis data at start of catch and finally blocks. NOTE: Fixing this issue led to an assert firing in CodeAnalysis dataflow operation visitor for an existing unit test, which has also been fixed in this PR
// If we are executing exception paths analysis OR have at least one try/catch/finally block | ||
// in the method, execute an exception path analysis post pass. | ||
// This post pass will handle all possible operations within the control flow graph that can | ||
// throw an exception and merge analysis data after all such operation analyses into the | ||
// catch blocks reachable from those operations. | ||
if (analysisContext.ExceptionPathsAnalysis || hasAnyTryBlock) |
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 the core fix
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## main #6828 +/- ##
==========================================
+ Coverage 96.36% 96.37% +0.01%
==========================================
Files 1401 1401
Lines 329956 330237 +281
Branches 10837 10841 +4
==========================================
+ Hits 317968 318272 +304
+ Misses 9256 9242 -14
+ Partials 2732 2723 -9 |
@@ -286,11 +291,9 @@ protected DataFlowAnalysis(AbstractAnalysisDomain<TAnalysisData> analysisDomain, | |||
|
|||
// Check if we are starting a try region which has one or more associated catch/filter regions. | |||
// If so, we conservatively merge the input data for try region into the input data for the associated catch/filter regions. | |||
#pragma warning disable CA1508 // Avoid dead conditional code - https://github.com/dotnet/roslyn-analyzers/issues/4408 |
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.
Nice!
Fixes #5199
Fixes #5160
Fixes #4984
We already had implementation and option based support to perform exception path analysis to handle all operations that can potentially throw an exception, and hence need flow analysis data at the point of operation to be merged with analysis data at start of reachable catch blocks from that operation. However, we were only performing this analysis post pass when flow analysis is looking at exceptions data. Now we do it for all analysis as this is required for more accurate input analysis data at start of catch and finally blocks.
NOTE: Fixing this issue led to an assert firing in CodeAnalysis dataflow operation visitor for an existing unit test, which has also been fixed in this PR