-
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
LVA: Add CfgSerializer.RoslynLvaWalker #9529
Conversation
d4fcd2f
to
27a7634
Compare
27a7634
to
bd720e2
Compare
new RoslynCfgWalker(writer, new RoslynCfgIdProvider()).Visit(cfg, title); | ||
return writer.ToString(); | ||
} | ||
public static string Serialize(RoslynLiveVariableAnalysis lva, string title = "RoslynCfg") |
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.
Not sure if it makes sense but I'd change the title to "RoslynCfgLVA" to avoid confusion in the future.
Like why I get this result here and another one in another case.
Like this, it might make it clear that this is a different CFG.
|
||
protected override void WriteEdges(BasicBlock block) | ||
{ | ||
foreach (var predecessor in lva.BlockPredecessors[block.Ordinal]) |
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 looks good but we are ignoring the ControlFlowBranches and their semantics - which probably should appear as edge labels :/
Please add couple of tests with while loops, if-else and foreach so we see how it looks there.
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 made some change to include semantic information 🎉
analyzers/tests/SonarAnalyzer.TestFramework/Extensions/StringAssertionsExtensions.cs
Outdated
Show resolved
Hide resolved
@@ -36,9 +36,21 @@ public RoslynLvaWalker(RoslynLiveVariableAnalysis lva, DotWriter writer, RoslynC | |||
|
|||
protected override void WriteEdges(BasicBlock block) | |||
{ | |||
foreach (var predecessor in lva.BlockPredecessors[block.Ordinal]) | |||
var lvaPredecessors = lva.BlockPredecessors[block.Ordinal]; |
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.
There's a lot of duplication now :/
Maybe it's possible to change what you need here and then call the base.WriteEdges?
Maybe you can also give the predecessors are input?
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.
Thre's quite some duplication now in the cfg walker.
544f856
to
aa051f6
Compare
Quality Gate passed for 'Sonar .NET Java Plugin'Issues Measures |
Quality Gate passed for 'SonarAnalyzer for .NET'Issues Measures |
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.
LGTM
The first commit is only CaYC.
I went a bit wild on cleaning...