<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/133322>133322</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[clang-tidy] Check request: readability-use-switch-statement
</td>
</tr>
<tr>
<th>Labels</th>
<td>
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
denzor200
</td>
</tr>
</table>
<pre>
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;
}
```
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJykU9tunDAQ_ZrhZcTKF64PPJBseGylqD9g7AHceCHFJlH69RXsJhttKu2qlZDAw7mMj3SU97YfiSpI7yDdR2oJwzRXhsbf0ywYi9rJvFXA6m9ExqNCPZB-wjCogK_WOezsaLaxsiMZtF1MzhP6oAIdaAyoRoN-6XvyAcO0Asee0G6HZUW-2qCH-IOwA1YDq-8emu-PDyDXb8jY6WG17RBEYRHkHuQeOYgSIb8DViMi-mBWiqz1tAQEeQ_yHkGIzs4-gBDvow8cjcaBXOmQ73Fb_cJB3ObgSU-j-TcLeZtFGOx83eEiL2B13fx4ePya5DH4bZGzv1aekB_B_xnoSm9nUk_H46YsrivfEuTfpOV16RsC_CxrqFOLC2fdT_--Bh2ZSppSliqiiueJ5JxLJqKhKvO0zLJUF5wVqU6zPEu4LvKuIJ0UGTORrQQTKZMiF1ymTOyytKSsKFhStLxreQEJo4Oybufcy2E3zX1kvV-o4lJKISKnWnL-vcFztaLiduk9JMxZH_yZF2xwW9e1U2MfB2veIN3j_VbqmX4t5Nf74kzKqNY6G97ixVN8WdJomV01hPDs13REA6LpbRiWdqenA4hmNTy94ud5-kk6gGi2rT2I5rT4SyX-BAAA__8vO0M_">