Issue 133322
Summary [clang-tidy] Check request: readability-use-switch-statement
Labels
Assignees
Reporter denzor200
    
Needs a check that will find a chained if-else statement and suggest to change it to use switch-statement.

BEFORE:
```
if (i == 1) {
    std::cout << "first" << std::endl;
} else if (i == 2) {
    std::cout << "second" << std::endl;
} else if (i == 3) {
    std::cout << "third" << std::endl;
}
```

AFTER:
```
switch (i) {
case 1:
    std::cout << "first" << std::endl;
    break;
case 2:
    std::cout << "second" << std::endl;
    break;
case 3:
    std::cout << "third" << std::endl;
 break;
default:
    break;
}
```

_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to