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

    <tr>
        <th>Summary</th>
        <td>
            [MLIR] Optional/Unit attribute extensions in ODS produce backwards-incompatible builder methods
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
      </td>
    </tr>

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

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

<pre>
    Recently, I've been trying to extend an op in a widely used dialect with an optional attribute. I expected this to be a fairly easy task, since the attribute would only be rarely used and would make sense to only be present optionally on the op. UnitAttr seemed like a good fit for that purpose.

However, it turns out that the C++ `build` methods generated by ODS after such an addition are backwards incompatible and break every single project that ever creates that op. This was quite surprising, as in many other languages and systems (Python, C++, ...) adding an argument that's optional or has a default at the end of the argument list is backwards compatible.

Is there a reason why ODS generated builder method force people to pass in `nullptr` for every single optional attr? It seems to me that it would make sense to at least add a `= nullptr` default in the header file for each such argument.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJxtVNmOm0AQ_Bp4aS0CvGD8wMMeWsVSoo1yfMDAtPHE4xkyxzrk69MN9notRUIGpq-q6sKdlVP7DXs0QU9J-QTbpFy_IXSIBoKblBkgWMA_AY0EYcCOoAwIOCmJeoLoUYJUQmMf6Czsl5ygrBEaRAhOdTFgBlvqMVISpYe98ty0Q-qzE8pRHxR-giD8gTF4ZXqkNLw2gJONWoI1lEt1Trj36YKALdGjOCB4NB65_SV3dEhn4R0VnVozd7djBj-NCg80herwSN20OjCswVoJOxVgZx3ligBjdKP1mCX5c5I_LL-f7Anf0DFmSg3RGQ82hqWAJzwl5SNdkNR5F5WWdIcjhr2VHgY06AQL0k3w-vwdxC4g4Yj9LKKQUjFgIKrQif5wEo6qSBp7HEVQncaZeudQHIBhTCzcoJmx_cX7mGFwBHpKCuiXE6b9g3dwEh5-R0XqeiLnFJczF8FjSE1DShELB1qYIYqBGvBEP_mARw9J2XydiIvhmjNTfsyyLCk3MwFyD1NxQzzyCng8-ctfHULq7mmcAIk7EXWAs3DsNrtbPHCp1soHINhXMa5S3Kxly0TR8R6JtycNT_tF4g-a8zqI2rINXjNZbkQ76tk8o_CzCLQwE7Ueg-PVsRlulL5xerJ6gW2YjTT7-4iL3mSN__mTIprQBRaKkFL_ZPUMH6ZdJFGLW_coGPBO0dwZiCCjLG45K5Sl2BZ1na_y-6KqUtmu5Ga1EWlQQWObVI9fPm-_JdUzvJ5hJ-UL-__DZzZ_6J6CM3uWjMwkY__Bgnc3FrzV0afR6XYfwuiT1QO1p2ugf4XYZVRDL1q_XW53Z5vSq_I-oqeHal0UTbpv63VfYF4VzaqRVVPIe9lUOT3JvqybTVGnWnSoPXMiPqlqy7ws86Yoi2JVVWWG62bXrO83Xb1u8rqvk_scj0LpjAdn1g2pa2cMXRw8Bdla_hqk5avBIF76i0jkXCvIFX8PmM5w2xnrP6xOz3o">