commit | 038ca4a18df162b50efcf7947035517662a3a90d | [log] [tgz] |
---|---|---|
author | Andrei Golubev <andrey.golubev@intel.com> | Mon Sep 15 16:13:18 2025 +0100 |
committer | Copybara-Service <copybara-worker@google.com> | Mon Sep 15 08:15:23 2025 -0700 |
tree | b62a87ca34be0695eade69687552a5a71eac1975 | |
parent | 4b647a3eed94397299e0e62468af7fd4808eb1b6 [diff] |
[mlir][TableGen] Emit interface traits after all interfaces (#147699) Interface traits may provide default implementation of methods. When this happens, the implementation may rely on another interface that is not yet defined meaning that one gets "incomplete type" error during C++ compilation. In pseudo-code, the problem is the following: ``` InterfaceA has methodB() { return InterfaceB(); } InterfaceB defined later // What's generated is: class InterfaceA { ... } class InterfaceATrait { // error: InterfaceB is an incomplete type InterfaceB methodB() { return InterfaceB(); } } class InterfaceB { ... } // defined here ``` The two more "advanced" cases are: * Cyclic dependency (A requires B and B requires A) * Type-traited usage of an incomplete type (e.g. `FailureOr<InterfaceB>`) It seems reasonable to emit interface traits *after* all of the interfaces have been defined to avoid the problem altogether. As a drive by, make forward declarations of the interfaces early so that user code does not need to forward declare. GitOrigin-RevId: f5d3cf4a643fc13194e09cb39905f7f3b083f85e
See https://mlir.llvm.org/ for more information.