Hacker News new | ask | show | jobs
by yencabulator 586 days ago
You can ask Clang for an AST that contains macro definitions and invocations as nodes.

https://docs.rs/clang/latest/clang/struct.Parser.html#method...

https://docs.rs/clang/latest/clang/enum.EntityKind.html#vari...

https://docs.rs/clang/latest/clang/enum.EntityKind.html#vari...

1 comments

Using clangd for this very much assumes that you have all include files and build flags available at the point of merge resolution, which is often pretty much impossible.
Agreed, it's not very robust the way tree-sitter is. I just thought that libclang trick was very useful for extracting semantic information from C source.