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

    <tr>
        <th>Summary</th>
        <td>
            clang-tidy does not understand `analyzer_noreturn` attribute
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            clang-tidy
      </td>
    </tr>

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

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

<pre>
    https://clang-analyzer.llvm.org/annotations.html#attr_analyzer_noreturn describes the `analyzer_noreturn` attribute:

> The Clang-specific 'analyzer_noreturn' attribute is almost identical to 'noreturn' except that it is ignored by the compiler for the purposes of code generation.

> This attribute is useful for annotating assertion handlers that actually can return, but for the purpose of using the analyzer we want to pretend that such functions do not return.

This attribute is not recognized/supported by clang-tidy, at least the `bugprone-unchecked-optional-access` check:

```cpp
#include <optional>

void myAssertFailedHandler() __attribute__((analyzer_noreturn));

#define MY_ASSERT(EXPR) \
  if (!(EXPR)) { \
    myAssertFailedHandler(); \
  }

void foo(const std::optional<int>& o)
{
    MY_ASSERT(o);
    // error: unchecked access to optional value [bugprone-unchecked-optional
 *o;
}
```

Changing the attribute to `noreturn` will cause the check to pass.

Should clang-tidy's data-flow analysis understand/respect this attribute?
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyEVU1v4zYQ_TX0ZWCDJmXJPujgeGP0skCxWaDtyaDIkcQuTQr8SOr99QWl2FbiYgsICUDOPL4382YsQtCdRazJ5olsvixEir3z9Vf9A_9AY9AvGqcudR_jEAjfE3Yk7CiNsN1SWGEuP9GvjHk9r5zvCDsKa10UUTsbVn08G8K4iNGfrrEn6zzG5C0oDNLrBgPEHoGU9CGElBRysm5SxPw2_ULo9S9_hu89wmFkEgaUutUSCKseYVh1hwEdQJizCxG0Qhu1FAaiy4nzePxH4hAh9iKCjjlJd_leQXMZ-Up3HrRBD63z48GQ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