Skip to content
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

review: fix(control-flow): Handle synchronized statement in CFG #5740

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

Mr-Pine
Copy link
Contributor

@Mr-Pine Mr-Pine commented Apr 5, 2024

Currently, a synchronized statement is completely ignored in the CFG. This PR adds it to the CFG properly.

@MartinWitt
Copy link
Collaborator

LGTM will merge

@@ -798,7 +798,11 @@ public <T, S> void visitCtSwitchExpression(CtSwitchExpression<T, S> switchExpres

@Override
public void visitCtSynchronized(CtSynchronized synchro) {
ControlFlowNode expressionNode = new ControlFlowNode(synchro.getExpression(), result, BranchKind.STATEMENT);
tryAddEdge(lastNode, expressionNode);
lastNode = expressionNode;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to preserve the synchronized statement itself in the graph? I.e. call defaultAction(synchro, BranchKind.STATEMENT) or w/e somewhere? Currently it looks like the synchronized is unrolled and no trace of it is left?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally yes, but in the current CFG model this is not possible in any way I like. This is one of the things I would like to improve with the redesign started in #5742

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants