Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suggestion: Replace libclang to clang ast-dump=json #2

Open
kassane opened this issue Dec 11, 2023 · 4 comments
Open

Suggestion: Replace libclang to clang ast-dump=json #2

kassane opened this issue Dec 11, 2023 · 4 comments

Comments

@kassane
Copy link
Contributor

kassane commented Dec 11, 2023

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

@LorenDB
Copy link
Owner

LorenDB commented Dec 14, 2023

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.

@kassane
Copy link
Contributor Author

kassane commented Dec 14, 2023

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
Copy link
Contributor Author

kassane commented Dec 14, 2023

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

@LorenDB
Copy link
Owner

LorenDB commented Dec 15, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants