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

    <tr>
        <th>Summary</th>
        <td>
            [clang-tidy] New check: modernize-use-static-assert-of-non-value-dependent
        </td>
    </tr>

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

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

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

<pre>
    Starting from C++23, `static_assert(false)` can be used directly in template definitions without causing immediate compilation errors, making various workarounds obsolete. I propose adding a new clang-tidy check that modernizes code by replacing deprecated patterns with the new C++23-compliant `static_assert(false)`.

EXAMPLE:
```
template<typename>
struct AlwaysFalse : std::false_type {};

template<typename T>
void foo() {
- static_assert(AlwaysFalse<T>::value, "Error message");
+ static_assert(false, "Error message");
}

template<typename T>
void bar() {
-    static_assert(false && sizeof(T), "Unsupported type");
+ static_assert(false, "Unsupported type");
}
```

This transformation is safe when:
1. The `static_assert` is inside a template
2. The expression is immediately false (not conditionally false based on template arguments)
3. The expression depends on one or more template parameters

</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJyUVNGK6zYQ_Rr5ZXCQ5cSOH_zgbDZQaEuhW-jbRbbGsbqyZDRy0uzXF9m52eXupbeFQAiZc87MHJ2RRPpsEWu2O7DdMZFzGJyvFdo35wXnSevUrf49SB-0PUPv3QhPTByYOIiciSdgBacgg-6-SCL0gYl9Lw0hExUrOHTSQoswEypQ2mMXzA20hYDjZGRAUNhrq4N2luCqw-DmAJ2cKarpcUSlY1XnxkkbGcsAvXeeovYoX2PZRXrtZoKr86_Su9kqAteSMxhwAz_B5N3kCEEqFcslWLxCZ6Q9p0GrG3QDdq8QBhlgdAq91W9I0DmF0N7A42RkF4EKJ4-dDKhgkiGgv7cMYcCF87GYNPZrtLThB_vZMN4w3jz_2fzy28_PLI8_WMHvH958XRPLn8JtQitHZPkz4w0FP3cBGnOVNzpFQmB5AxRUJMmbReNLxAArD6w8svywan2HEl5W0ovTCnrnmNgzUS1A3qTwbf8fRFn-tGAXzYs0My5vQojnaBKMSCTPyISI464diMMnwvtCfgAsj_9tgFb6bwYA-L4kMFEwUQDpN3Q9E_uXqLb28YeleZqcj25Hmf8zw79i1zE-eMx48zJoguClpd75cX3mmoBkj3Ad0K4PI9vAy4CfX1TBY7G2pBWCfESL8UasCPx78kh0Z32kytzg6xr21gXonFVLEqV5_NXKmFz3IbDSn-cRbaA4Em_yTxIKJ1wiaMFZhOim8_hOMEkvRwzoifEmUXWuqrySCdZZWVRllhVFkQx1qbqqr3K-Ffs-L7NetW2JJd9vu0puVYWJrgUXBc9Ele3zrSg2eVl0PS_VNiu2fKd2bMtxlNpsjLmMG-fPiSaao8y-FFliZIuGlrsnxPs1iF7tjomvIypt5zOxLTeaAr3zBB3McjE_wHZH-DWelXhLYhIflySdCdPVsHQ1LHV9ap1Nl7yk67rQhmT2ph5CmCjaLU5MnM46DHO76dzIxCnK37_Sybu_sAtMnJaZiInTfaxLLf4JAAD__yCX5os">