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

    <tr>
        <th>Summary</th>
        <td>
            Improve error detection for AttrOrTypeDef.assemblyFormat
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            tablegen,
            mlir
      </td>
    </tr>

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

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

<pre>
    When an `AttrOrTypeDef` sets the `assemblyFormat` field, the generated parser requires there to exist a builder with the same prototype as the default-builders, or else the C++ compiler will fail. However, we do not want to require `skipDefaultBuilders=0` per se, since some clients may want to use a custom definition of the "default" builder.  Commits 46394861a330 and c0db2b75ac1c introduced some basic checking for this error condition, so that users can see tablegen-time error messages rather than C++ compiler error messages. However, those commits only look at the `skipDefaultBuilders` field and so are prone to too many false positives.

I am working on a commit for detecting whether one of the custom `builders` matches the default prototype, but this approach is inherently fragile since it's using string-equality for matching C++ types; so it can reduce the false positives, but it will still have some.

The only other approach that comes to mind is adding a new `bit hasCustomDefaultBuilder` field (with some better name!) for users to signal that we should generate the default-builder declarations but not their definitions (similar to how `hasCustomAssemblyFormat` relates to `assemblyFormat`).
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJxtVE1z4ygQ_TXyhYpLlmzFOeiQxJXaOe1lqvbcgrbEBIEHkD3-9_NAcjLeSdllCQPd7ws6p67tfwNbQVYUTfkco__Xf7-e-MBHjEXgGEQcOE1SCDx25vrm_EgxzR41G1VUr3lFz5Y9RVbiRD6wF55_Ttpz3u9ZRCf4lw5RkOgmbRRWXHQc8t5AI4uTd9FF9BY091R8pMnEh2V5SJ2cF2wC5_nXonrBV0g3nrTJ9YwRR9JmLf5xFz6zT1suqOSEdVFcyMaEY0GWSIV3fTrMfV5ubepDmdidUDFwqhC0lQDpAFIazRaajHT9KDcBDwk5hejGBFpbHbW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