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

    <tr>
        <th>Summary</th>
        <td>
            [clang-tidy] Create modernize-macro-to-function check for function-like macros that compute values
        </td>
    </tr>

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

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

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

<pre>
    In a fashion similar to modernize-macro-to-enum, identify function-like macros that expand to an expression of their arguments and literals.  Convert those macros to template functions.  For example:

```
#define FOO(x_) ((x_)/100)
```
becomes (assuming C++14 for deduced `auto` return type)
```
template <typename T>
auto FOO(T x_) { return ((x_)/100); }
```

To be selected for conversion the macros must follow constraints similar to modernize-macro-to-enum:

- Macros must expand only to valid whole expressions of constants and macro arguments.
- Macros must not be defined inside a conditional compilation block.
- Macros must not be used as arguments to other macros.
- Macros must not be defined inside a declaration or definition.
- Macros must not be undefined.
- Macro arguments must only be used as values, not as types or other elements of the language.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyVVE1v2zAM_TX2hUjg-CNpDj40yQIM2NBL74MsMbYWWQr00Tb99aNsp02xtNgAwxZN6vGRfFJjxLn-roHBgblOGg1O9lIxC95AbwRaLV9x1jNuzcybGerQJ_kWpEDt5eEMh6C5p30zJY8IQ5wD3zEP-HJiWkQcpqNh0bmYwBzIj9ICs23oCcZBjFPSo2XKzQG2Rj-h9RRm3DumAY_9STGPb0lj8N5YQmfkwaS4T7Jdkl3ey2x6RjMvBB6kRtg_PCT53cuvJF8DLS7rJN8vsiwubm1vkJseXdzAnAu91C1sk3xDz6KEA7EQKAJHAbSFBW_oAxZ9sBr8-YSf4b4VlRTbGKdZj_CYFN9Gd0SaCD_CRHm1uQDfZF9sKGR3uwfD-9FAg-BQIffEN3LnQ8uH-dBwLj3vg_PkVso8xwjnLZNxXv-gkY-jmMHPK8RJGUarc4R4YkoKeO6MwiuduCiUISm7SGTI8C6b-S1sbXwsbpy0AKkdSZXkTUhCRs0wRev-RPyjBY0y_PgVUnAEw9yVWomyoSbZqUv_RUMgp8aNqQfJkH-g9SUFPeF8DLqiNEQP_bxiTH0N6OJpjTj0I8rLxbQjfZr_uHs8kaCYbgNrcZ6KuhDrYs1SL73COqk2PDpnXopzUu1gazEq9sbsLycTeIf8OEjr8xsiziEQzkg0DVbVnfcnF8WT7-lppe9CM6c4MpR6unxmJ2t-k3jJlHQWY5H7qsqzLO1qlpUVX1Z3fFWW7EBGs2ILzPI7xLxhrEkVa1C5WFSS56g7pvnQB7Jir-hzVSz9q3aprPMsz7OyyLJFuSyqeblel-umWhaLRbMSvEzKDHsm1TyymxvbprYeiDahdeRU0pFe35x0gchWI04kfmBLR-AV70VQdOcZMaWls98ZW__lToei66HiP6sy59U">