<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/62923>62923</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            `-Wsometimes-uninitialized` suggests unhelpful removal of if statement
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            clang:diagnostics
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          tbaederr
      </td>
    </tr>
</table>

<pre>
    See: https://godbolt.org/z/cGe68aK11

The output for:
```c++
int f1(int cond) {
  int a;
  if (cond) {


  } else {
    a = 3;
  }
  return a;
}
```

with `-Wsometimes-uninitialized` is:
```console
<source>:3:7: warning: variable 'a' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized]
 if (cond) {
      ^~~~
<source>:9:10: note: uninitialized use occurs here
  return a;
         ^
<source>:3:3: note: remove the 'if' if its condition is always false
  if (cond) {
 ^~~~~~~~~~~
<source>:2:8: note: initialize the variable 'a' to silence this warning
  int a;
       ^
        = 0
1 warning generated.
ASM generation compiler returned: 0
<source>:3:7: warning: variable 'a' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized]
  if (cond) {
      ^~~~
<source>:9:10: note: uninitialized use occurs here
  return a;
 ^
<source>:3:3: note: remove the 'if' if its condition is always false
 if (cond) {
  ^~~~~~~~~~~
<source>:2:8: note: initialize the variable 'a' to silence this warning
  int a;
       ^
        = 0
1 warning generated.
```

the suggestion to remove the if statement is is pretty useless, and just adds noise to the output. I think it would be pretty safe to simply remove this diagnostic.

/CC @cjdb @AaronBallman @nikic

</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzUVkuP4zYM_jXMhZjAkfzKwYfMZFMURU9boGfZpmPNylIgShPMHua3F8o73Qn21odg2LIokd_3kQmtmPXWEjVQPEOxnqkYRueb0CrqyftZ6_r35isRyBWOIewY5ArEBsRm6_rWmTB3fgti8x3EpvuFylr9tlhAtoZsdbz_MRK6GHYx4OB8On00ltnx6kA8p-uwqm3AYQGiTpPO2R7EEqE6WRHTsgJ5fR8QRP3Dxts7IlRrJMN06whRIcg1yhtnUK3PU08hensT6mK74L6NsddhRCizpz_ZTRT0RPwUrbY6aGX0d-qhzFDzJ-SdZWfotCpf2EXfEcgvIFcS5KpKsu-Vt9pu0_RNea1aQwiiUiAq1IyRqce7aLgfydIb-bRND2lfkkgH7Ww6EXwkhOL5MdzirMQDgfEwoPjy8fHxKfglyNUiS5CtC4fiuUcYmdB1XfSMI3l6qDueBxRfHqokb-N4mtwbYRjpyl4PqAPfi6DMXr0zDsow_aScTkRP41MYAuSqvoVxJXuA8kPigkPWhmyX7JovSX5Q6PcaXESRazwV4uLsAbdkyatA_fxoWX39_byWqHdu2mlD_qQ19Qlt9t-twH-_BP-J0ntI8n9dep_-WSZMHLdb4oMewd3qpgfkoAJNZEOSSjPuPIXwntJliBnECyrb42vkgKrvGa3TTMlNuHSaOf6aqNlvqAPuXTQ9tnR2xGqgowbTzrxfg2vGXqutdRx0N79rJGLz8oKQZ91r36bnSnlnn5Uxk7Lp3epvujvunfWN7JdyqWbULMo6X-aiFHI2NrWgrqqXpWqpKoYhV3ld1rXIa1FQlZeLmW5EJmRWiHxRyLKo5kVW9JKWRUmlyHu5gDyjSWkzN-ZtSm13ppkjNaVYCjkzqiXDhzYuRGfU4ed6JcQgROrvvkmnn9q4Zcgzoznw1V_QwVDzs0Z2Sh5jtCOZ3RDNUURl0A13GZxFb5q_fTXoMMZ23rkJxCYFPj2edt69UhdAbA6sGMTmQOyvAAAA__8clJh-">