I’m currently working on a custom dialect for MLIR and this dialect requires custom attribute parsing. I already saw [RFC] Exposing MLIR's Tokenizer, Lexer and Parser and accepted the fact that I had to write this on my own. Unfortunately there is a problem with precise error emission:
My custom parser works with SMLoc
s that then should be converted to a Location
but this conversion cannot be done precisely for now. The normal parser uses a SourceMgr
that provides functionality to convert pointers to FileLineColLoc
s but this is hidden away.
The only solutions we (@Kayjukh and I) were able to find, introduce either a coupling of the DialectAsmParser
with my custom one or require an error-callback lambda that itself invokes DialectAsmParser::emitError
with the SMLoc
s.
Is there a reason why one is not able to access the SourceMgr
or anything else that allows this conversion for custom parsing?