INRIA / INRIA/spoon

[Bug]: Control Flow Graph doesn't handle cases with multiple expressions

Open
#5,731 0 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Java
Stars
2k
Forks
392
Avg merge
11h 24m
Merged PRs (30d)
36

Description

### Describe the bug

In a case statement with multiple expressions, only the first expression is represented in the CFG:
![image](https://github.com/INRIA/spoon/assets/50425705/5ccb6fd0-9634-48ef-9493-24f713c89a17)

Expected would be something like this:
![image](https://github.com/INRIA/spoon/assets/50425705/8eabc3fe-10b3-4a4a-b565-d1cbabd653e5)

### Source code you are trying to analyze/transform

```Java
public int mySwitch() {
int a = 0;
switch (a) {
case 1, 2: break;
default: break;
}
}
```

### Source code for your Spoon processing

```Java
testMethod("mySwitch", false, null, null, null); // with testMethod from the cfg test class ForwardFlowBuilderVisitorTest.java
```

### Actual output

_No response_

### Expected output

_No response_

### Spoon Version

10.4.2 / Control Flow 0.0.2-SNAPSHOT

### JVM Version

21

### What operating system are you using?

Linux

Contributor guide

Open the contributing guide

Research direction

Start with ForwardFlowBuilderVisitorTest.java and its testMethod("mySwitch", false, null, null, null) case. Reproduce the CFG for the switch containing case 1, 2, then trace how multiple case expressions are represented. Done means the CFG includes both expressions and the regression test passes.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
compilers
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.