polyglot
polyglot copied to clipboard
Suggestion: Replace `libclang` to `clang ast-dump=json`
Hi @LorenDB,
Based on:
$> clang -x c++ -Xclang -ast-dump=json -fparse-all-comments [cpp|cc|h|hpp|hxx files]
# or (minimal)
$> clang -x c++ -Xclang -ast-dump=json -fsyntax-only [cpp|cc|h|hpp|hxx files]
Also used on c2z(C++ to Zig bindings [generator]), replacing clang
to zig cc
and add -lc++
(llvm-libc++) flag.
The purpose is to make your application more portable with no LLVM dependencies.
another reference
- https://github.com/standardese/standardese/issues/242
that looks interesting, but is there a reason to not require LLVM? Do other apps support generating a Clang AST JSON file?
I'll be happy to integrate this if there's a significant benefit to it, but if we have to install Clang anyway I'd prefer to keep linking against Clang for code simplicity.
In addition to Zig which has portable LLVM. Until now, I don't know!
Having libclang means the user is forced to have the LLVM (+ clang) toolchain. There are some Linux distributions that subdivide the LLVM and clang package.
Even, if the project does not add C macros support. Then ast-dump will be enough. Preprocessors is not translated in clang AST.
I'll think about it but I'm not sure that I'm ready to put in the effort yet.