Commit a073bbb
[CIR][CodeGen] Handle the case of 'case' after label statement after 'case' (llvm#879)
Motivation example:
```
extern "C" void action1();
extern "C" void action2();
extern "C" void case_follow_label(int v) {
switch (v) {
case 1:
label:
case 2:
action1();
break;
default:
action2();
goto label;
}
}
```
When we compile it, we will meet:
```
case Stmt::CaseStmtClass:
case Stmt::DefaultStmtClass:
assert(0 &&
"Should not get here, currently handled directly from SwitchStmt");
break;
```
in `buildStmt`. The cause is clear. We call `buildStmt` when we build
the label stmt.
To solve this, I think we should be able to build case stmt in
buildStmt. But the new problem is, we need to pass the information like
caseAttr and condType. So I tried to add such informations in
CIRGenFunction as data member.1 parent 183567b commit a073bbb
File tree
3 files changed
+77
-20
lines changed- clang
- lib/CIR/CodeGen
- test/CIR/CodeGen
3 files changed
+77
-20
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
478 | 478 | | |
479 | 479 | | |
480 | 480 | | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
481 | 488 | | |
482 | 489 | | |
483 | 490 | | |
| |||
1210 | 1217 | | |
1211 | 1218 | | |
1212 | 1219 | | |
1213 | | - | |
1214 | | - | |
1215 | | - | |
| 1220 | + | |
1216 | 1221 | | |
1217 | | - | |
1218 | | - | |
1219 | | - | |
| 1222 | + | |
1220 | 1223 | | |
1221 | 1224 | | |
1222 | 1225 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
303 | 303 | | |
304 | 304 | | |
305 | 305 | | |
306 | | - | |
307 | | - | |
| 306 | + | |
308 | 307 | | |
309 | 308 | | |
310 | 309 | | |
| |||
715 | 714 | | |
716 | 715 | | |
717 | 716 | | |
718 | | - | |
719 | | - | |
720 | | - | |
| 717 | + | |
| 718 | + | |
| 719 | + | |
| 720 | + | |
| 721 | + | |
| 722 | + | |
721 | 723 | | |
722 | | - | |
| 724 | + | |
| 725 | + | |
723 | 726 | | |
724 | 727 | | |
725 | | - | |
| 728 | + | |
| 729 | + | |
726 | 730 | | |
727 | 731 | | |
728 | 732 | | |
| |||
987 | 991 | | |
988 | 992 | | |
989 | 993 | | |
990 | | - | |
991 | | - | |
992 | | - | |
| 994 | + | |
993 | 995 | | |
994 | 996 | | |
995 | 997 | | |
996 | 998 | | |
997 | 999 | | |
998 | | - | |
| 1000 | + | |
999 | 1001 | | |
1000 | 1002 | | |
1001 | 1003 | | |
| |||
1045 | 1047 | | |
1046 | 1048 | | |
1047 | 1049 | | |
1048 | | - | |
| 1050 | + | |
| 1051 | + | |
1049 | 1052 | | |
1050 | | - | |
| 1053 | + | |
1051 | 1054 | | |
1052 | 1055 | | |
1053 | | - | |
| 1056 | + | |
| 1057 | + | |
| 1058 | + | |
| 1059 | + | |
1054 | 1060 | | |
1055 | 1061 | | |
1056 | 1062 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
310 | 310 | | |
311 | 311 | | |
312 | 312 | | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
0 commit comments