24 Commits
Author SHA1 Message Date
Greg Shuflin 022136d7dc Fix isFromMainFile for macro-argument function names (BZ_API pattern)
For declarations whose names are macro arguments (e.g. BZ_API(func) in
bzip2), the raw CXSourceLocation is a MacroID. When
clang_Location_isFromMainFile dereferences that MacroID it follows the
expansion chain, which can land in an intermediate scratch buffer rather
than the main file, incorrectly returning false.

Fix: use clang_getExpansionLocation to get the concrete file/line/col,
then reconstruct a file-based location via clang_getLocation and check
clang_Location_isFromMainFile on that instead.
2026-05-18 20:08:32 -07:00
Greg Shuflin 6595eff1cb Remove world argument from C shim 2026-05-18 03:49:50 -07:00
Greg Shuflin 9d22695f0c Replace clang_Cursor_Evaluate with token-based macro body parsing for evaluateCursor 2026-05-15 15:02:16 -07:00
Greg Shuflin ae18763054 Add macroDefinition cursor kind, flags param for parseTranslationUnit, and evaluateCursor 2026-05-15 14:56:06 -07:00
Greg ShuflinandClaude Sonnet 4.6 5bfd26b703 Add getCursorNumArguments, getCursorArgument, getCursorResultTypeSpelling
Provide dedicated APIs for inspecting function arguments and return types.
These are more reliable than getChildren + type string splitting for headers
that use macro-based calling conventions (e.g. SDL_DECLSPEC/SDLCALL), where
parameter cursors may not appear as AST children in the expected way.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-15 04:24:00 -07:00
Greg ShuflinandClaude Sonnet 4.6 650b667a79 Add getCursorEnumConstantValue and getCursorEnumConstantUValue
Exposes clang_getEnumConstantDeclValue and
clang_getEnumConstantDeclUnsignedValue so consumers can
read the numeric value of enumConstantDecl cursors without resorting
to string parsing.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-15 04:23:52 -07:00
Greg Shuflin be890d5a1a Fix justfile 2026-03-23 20:11:13 -07:00
Greg Shuflin 1251299c84 Fix linker arguments
This has to do with the fact that I install elan from nix, it's using
the nix linker which needs to be told where non-nix libraries are
2026-03-23 20:02:33 -07:00
Greg Shuflin 84052ec6f1 Build process: log info about libraries 2026-03-23 00:44:21 -07:00
Greg Shuflin 8a0c07ff5a C shim style 2026-03-23 00:41:24 -07:00
Greg Shuflin e4b326a923 More tweaks 2026-03-22 22:44:14 -07:00
Greg Shuflin 3293719149 Tweaks to build process 2026-03-22 18:27:26 -07:00
Greg Shuflin 3bff5bac8c Correct linker flag 2026-03-21 04:14:28 -07:00
Greg Shuflin 9833033339 C shim formatting 2026-03-21 04:14:15 -07:00
Greg Shuflin 6045f1af0b Remove .envrc 2026-03-21 04:13:58 -07:00
Greg ShuflinandClaude Opus 4.6 27890be7a2 Add nix build output and justfile
Add packages.default flake output that builds the lean-libclang binary
via nix build. Add justfile with build, run, nix-run, and clean recipes.
Add 'result' to .gitignore.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-19 04:38:22 -07:00
Greg Shuflin 3569373c6f String representation of CursorKind 2026-03-19 04:28:18 -07:00
Greg Shuflin 1dc83a7d37 getCursorLocation work 2026-03-19 04:20:13 -07:00
Greg Shuflin 7fce7fd415 getCursorKindRaw can be private 2026-03-19 03:53:35 -07:00
Greg Shuflin 47f6cc1147 Move CursorKind into its own file 2026-03-19 03:48:20 -07:00
Greg ShuflinandClaude Opus 4.6 f2e84173b9 Add README with build instructions and API usage example
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-19 01:03:56 -07:00
Greg ShuflinandClaude Opus 4.6 c40867f345 Add isFromMainFile and isInSystemHeader bindings
Wraps clang_Location_isFromMainFile and clang_Location_isInSystemHeader
from CXSourceLocation.h. Main now filters AST traversal to only show
nodes from the main file, skipping declarations from #include'd headers.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-18 10:54:49 -07:00
Greg ShuflinandClaude Opus 4.6 b5eab38a20 Add thin FFI bindings to libclang with Nix flake
Phase 1 implementation: C shim wrapping libclang's cursor-based AST API,
Lean 4 opaque types and extern declarations, and a Nix flake for hermetic
builds. Each Cursor holds a refcounted reference to its TranslationUnit
to prevent use-after-free from Lean's GC.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-18 09:37:43 -07:00
Greg Shuflin 02cc1ce363 Initial commit 2026-03-18 02:53:24 -07:00