Re:Mergiraf: a syntax-aware merge driver for Git
by yencabulator on Monday November 11, 2024 @02:32PM
(#42109804)
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...
Re:Mergiraf: a syntax-aware merge driver for Git
by Sesse__ on Monday November 11, 2024 @05:43PM
(#42111123)
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.
Re:Mergiraf: a syntax-aware merge driver for Git
by yencabulator on Monday November 11, 2024 @05:51PM
(#42111172)
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.
Of course, the existence of the preprocessor means there are situations where it's completely impossible to know what the correct parse is; it will necessarily be heuristic in some cases.