I’m trying to get rid of using namespace mlir; from Flang headers (in particular, this one). However, that leads to build errors:
tools/flang/include/flang/Optimizer/Dialect/FIROps.h.inc:3401:117: error: unknown type name 'TypeAttr'; did you mean 'mlir::TypeAttr'?
static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, TypeAttr in_type);
^~~~~~~~
mlir::TypeAttr
I’ve tried editing references to TypeAttr in FIROps.td, but to no avail. I experimented with "mlir::AttrType" and a few other variants, but that led to:
I’m not familiar enough with tablegen outside of option parsing to say the canonically correct way of doing this. But to scope the type import down to just TypeAttr, you can use this instead:
using mlir::TypeAttr;
That’s not really much better in a header file, but at least the entire namespace isn’t being imported.
In fact, I am getting a lot of similar build failures for other attributes too (i.e. error: unknown type name 'TypeAttr'; did you mean 'mlir::TypeAttr'). I just got fixated on this particular one. My bad, sorry! Now I need to figure out why one of them is correctly namespaced and the other one is not. Any suggestions?
But to scope the type import down to just TypeAttr , you can use this instead:
Good point! But there’s quite a few of them (again, I didn’t pay attention earlier)
Thanks both, this is a step forward for me after a rather unproductive afternoon!
Technically the last one is the fully qualified one: you can always use it (in C++ context). The second one work as well in most case, but could break if there is a nested mlir namespace in one of the enclosing namespaces I think.