-
Notifications
You must be signed in to change notification settings - Fork 229
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
Fix S1854 FP: Value used after catch #9531
Conversation
2b83ac1
to
c2880fa
Compare
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 don't think the approach is sound.
@@ -124,7 +125,7 @@ private void BuildBranches(BasicBlock block) | |||
if (block.EnclosingNonLocalLifetimeRegion() is { Kind: ControlFlowRegionKind.Try } tryRegion) | |||
{ | |||
var catchesAll = false; | |||
foreach (var catchOrFilterRegion in block.Successors.SelectMany(CatchOrFilterRegions)) | |||
foreach (var catchOrFilterRegion in block.Successors.Union(Cfg.Blocks[tryRegion.LastBlockOrdinal].Successors).SelectMany(CatchOrFilterRegions)) |
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.
For me this approach looks more natural:
foreach (var catchOrFilterRegion in block.Successors.Union(Cfg.Blocks[tryRegion.LastBlockOrdinal].Successors).SelectMany(CatchOrFilterRegions)) | |
foreach (var catchOrFilterRegion in CatchOrFilterRegions(tryRegion.EnclosingRegion(ControlFlowRegionKind.TryAndCatch))) |
This is only to show the idea, the implementation needs to be a bit different (this currently throws in a using statement). But the idea would be for every block to look at the enclosing try-catch
region and add branches to all catch
regions.
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 don't understand.
I need the leaving regions of the try region.
7a275bd
to
ff769a1
Compare
eec2cf3
to
7e21ddd
Compare
Quality Gate passed for 'Sonar .NET Java Plugin'Issues Measures |
Quality Gate passed for 'SonarAnalyzer for .NET'Issues Measures |
Fixes #9467