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

    <tr>
        <th>Summary</th>
        <td>
            [MLIR] Build issues when enabling mlir/tblgen-to-irdl
        </td>
    </tr>

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

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

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

<pre>
    I encountered a build error when compiling the `tblgen-to-irdl` tool in MLIR. The error is due to an ambiguous reference to NoneType, which is defined in both MLIR (`mlir::NoneType`) and LLVM (`llvm::NoneType`).

Using gcc-13.3

Error:
```bash
.../llvm/mlir/tools/tblgen-to-irdl/OpDefinitionsGen.cpp: In function ‘std::optional<mlir::Type> recordToType(mlir::MLIRContext*, const llvm::Record&)’:
.../llvm/mlir/tools/tblgen-to-irdl/OpDefinitionsGen.cpp:124:12: error: reference to ‘NoneType’ is ambiguous
  124 |     return NoneType::get(ctx);
      |            ^~~~~~~~
```

Resolved with the following patch:
Qualify the symbol explicitly as `mlir::NoneType::get(ctx)` in OpDefinitionsGen.cpp to disambiguate.

```
- return NoneType::get(ctx);
+ return mlir::NoneType::get(ctx);
```
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJysVE1v6zYQ_DXUZWGBpixZPuigfKgIkNeiQdo7Ra4kFjQpkFQSX_rbC1L-eEFzyOERhg1IO8uZ2fFy79VoEBtS3pHyIeNLmKxreM_HxWMIp6y38tQ8ARphFxPQoQQO_aK0BHTOOnif0ICwx1lpZUYIEwKpaOj1iGYT7EY5qUlFIVirQRn48fz0ksPrhGe88iAXhGCBG-DHXo2LXTw4HNChEenN79bg62lGwu7hfVJiSigclEEZe_Y2TKkxEFaTih61cqRoSdFekRUl7ADcSHh-_vvHuU7rt-NXdTmhLaHtXz4qGoXYbIu8WJ89RtIRQ9tYmz499xOhbZ7nhHWpJ-sSBdZF1T7-fvaDdX_MD5G_Csoa_xuaXMwzKVp4MjAsRsTHQB4ZqSk51D7Ilaad4wuuSXF_05h4F4_gUFgnX-3qVH0riM7cWxPwIxDWRhOFNT7ATf5LghJWEXa43HpYVf4KVVu2S99RIJ4N_Dzhq9TrIC4s4qivsSC0BdiyHZD9PcTjMCzO3AKS1IwYCKtF-IhqirsEiucCOh9SPv67np-HuY75Bb3VbyjhXYUphXqwWtv3GIiZBzGt5vy5cK2GUyrwp2NvNeDHrJVQQZ-Ae_g6jP9nWdGY46_si-5I5VcLeMBzNn_mu_muDYTdXUq_xWoFXW7KZFPIQ3HgGTbbfVnvWVlVdTY1w8CKgvJC0EII1h9qlEVPkW1R1JWU-0w1jLKSHthuuyt3rM63db8f9rLc0XJgomJkR_HIlc5jznLrxkx5v2CzrWhZ7DPNe9Q-LSnG1gyyuK5cE-s3_TJ6sqNa-eBvHYIKOi22GH9SPsBd2lqpsV_XFhrep611yfWnPGeL080UwuyjNawjrBtVmJY-F_Z4-08kCrOz_6AIhHVrf8K6M_e3hv0XAAD__4F9rWo">