c2rust
c2rust copied to clipboard
`ASTExporter` doesn't support built-in macros, like `__LINE__`
It's listed as a TODO: https://github.com/immunant/c2rust/blob/master/c2rust-ast-exporter/src/AstExporter.cpp#L647
List of builtin macros starts at Line 148: https://clang.llvm.org/doxygen/Preprocessor_8h_source.html
I'd be willing to do the translation work, eg converting __LINE__
to line!()
, I just need to know the general structure and where to look. Any help is appreciated!
Thanks for opening this issue @ijustlovemath. We're happy to review your patch if you open a PR.
I recommend looking at the PR that adds support for const macro's as a starting point: https://github.com/immunant/c2rust/pull/87.
@thedataking @rinon Where is the actually lookup table conversion happening here? Is it through cbor_encoder_*
? the macros
map? I just need to know what to populate, seems like a lot of the hard work is done already!
It seems like the macros
map is a logical place to start, but I can't see where it's getting its values. I suspect I'm missing some place where there's some kind of reference-based c++ magic happening here.
@ijustlovemath I recommend you spend some time familiarizing yourself with the code, maybe stepping through key parts of a minimal input sample in a debugger. I wish we had more time to guide you through the process at a more granular level, but unfortunately we do not.
Just an educated guess, but I would start by checking here https://github.com/immunant/c2rust/blob/master/c2rust-ast-exporter/src/AstExporter.cpp#L646-L648 to see if the __LINE__
macro is recoverable at that point. If it is you can export it as either a new tag (see ast_tags.hpp
) or a function call to a builtin.