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.
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>
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>
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>
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>
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>