polyglot icon indicating copy to clipboard operation
polyglot copied to clipboard

Suggestion: Replace `libclang` to `clang ast-dump=json`

Open kassane opened this issue 1 year ago • 4 comments

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

kassane avatar Dec 11 '23 16:12 kassane

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.

LorenDB avatar Dec 14 '23 20:12 LorenDB

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.

kassane avatar Dec 14 '23 20:12 kassane

Even, if the project does not add C macros support. Then ast-dump will be enough. Preprocessors is not translated in clang AST.

kassane avatar Dec 14 '23 20:12 kassane

I'll think about it but I'm not sure that I'm ready to put in the effort yet.

LorenDB avatar Dec 15 '23 00:12 LorenDB