‘MemRefType’ is not a member of ‘mlir’

Hello, I have created my own dialect which consists few instructions. One of them is a store like operation with 1 extra input. Everything was fine until I recently upgraded my Polygeist and MLIR. Now this is the error I see.

Aside from the error in title, I am also seeing:
request for member ‘getType’ in ‘((mlir::toylang::StoreNewOp*)this)->mlir::toylang::StoreNewOp::getMemref()’, which is of non-class type ‘int’.

Please let me know if you have encountered similar problems and how you solved them, thank you!

I suspect this isn’t the first error in your log and there is an earlier error that should be addressed first.

Hi @mehdi_amini , thank you for your reply. This is the first error and a portion stack traces example looks like this :
In file included from …/include/Example/Dialect/toylang/toylang.h:44,
from lib/Dialect/toylang/toylang.cpp:7:
/Dialect/toylang/toylang.h.inc:167:30: error: ‘MemRefType’ is not a member of ‘mlir’
167 | ::mlir::TypedValue<::mlir::MemRefType> getMemref();
| ^~~~~~~~~~
/Dialect/toylang/toylang.h.inc:167:40: error: template argument 1 is invalid
167 | ::mlir::TypedValue<::mlir::MemRefType> getMemref();
| ^
In file included from /Dialect/toylang/toylang.cpp:275:
toylang/toylang.cpp.inc:397:40: error: no declaration matches ‘mlir::TypedValuemlir::MemRefType mlir::toylang::StoreNewOp::getMemref()’
397 | ::mlir::TypedValue<::mlir::MemRefType> StoreNewOp::getMemref() {
| ^~~~~~~~
In file included from …/include/toylang/toylang.h:44,
from Dialect/toylang/toylang.cpp:7:
/Dialect/toylang/toylang.h.inc:167:42: note: candidate is: ‘int mlir::toylang::StoreNewOp::getMemref()’
167 | ::mlir::TypedValue<::mlir::MemRefType> getMemref();
| ^~~~~~~~~

toylang.h is including toylang.h.inc, and at the point of that inclusion, you don’t have the right header includes – you are missing the include for MemRefType. Hence, the compiler doesn’t know about MemRefType when compiling the code from toylang.h.inc. Just ensure that you include the header for MemRefType by the time toylang.h.inc is included.

@bondhugula Thank you so much! That’s exactly what happened. I accidentally included a toylang.h.inc somewhere else in a different file that’s causing the problem. Really appreciate the help!

That was the error I was missing from the original post (I didn’t see the title: better post the log like you did after). @bondhugula pointed to the right solution (this is a missing include for the header that defines this type).
The .inc files should always be wrapped in a .h you write to make them “self contained” and ready to include :slight_smile:

Hi @mehdi_amini ,yes sorry I will post the stack trace from now on. Thank you so much for the help!

1 Like