Releases
Unreleased
Platform Support
- Add macOS support using Xcode's built-in clang/libclang.
- Add Windows MSVC (mswin) support using Visual Studio's bundled LLVM/Clang, including system include path discovery via
vcvarsall.batandclang-cl. - Improve Windows MinGW support.
- Work around LLVM bug #154361 where
FreeLibraryonlibclang.dllcrashes during process exit due to dangling Fiber Local Storage callbacks (fixed in LLVM 22.1.0).
Breaking Changes
- Index:
Index.newnow takes keyword options matching libclang's modernCXIndexOptionsAPI rather than the old positional boolean constructor. The publicIndex.create_with_optionswrapper has been removed; the wrapper surface is nowIndex.new(...).
Bug Fixes
- Fix
FFI::Clang::TranslationUnit#default_reparse_optionscalling wrong libclang function. - Fix
CXIndexOptionsstruct layout to match libclang's bitfield packing (24 bytes on Linux/macOS, 32 bytes on Windows). - Fix
FFI::Clang::TranslationUnit#saveto use libclang default save options instead of hardcoded zero. Accept optional save option flags. Enumerable#eachmethods onclass FFI::Clang::Tokens,class FFI::Clang::Comment,class FFI::Clang::CodeCompletion::Results, andclass FFI::Clang::CompilationDatabase::CompileCommandsnow return anEnumeratorwhen called without a block.- Fix the
clang_getNullRangebinding to returnCXSourceRangeinstead ofCXSourceLocation. - Ensure
require "ffi/clang"loadsFFI::Clang::VERSIONwithout requiringffi/clang/versionseparately. - Update
CXCursorKindto match current clang headers, including newer C++ expression kinds, OpenMP/OpenACC statement kinds, andConceptDecl. - Update
CXTypeKindto match current clang headers, including newer builtin and HLSL type kinds. - Update
CXCallingConvto match current clang headers, correctingX86RegCalland addingRISCVVLSCall_*calling conventions. - Update
CXCodeComplete_Flags,CXCompletionContext,CXCommentInlineCommandRenderKind,CXEvalResultKind,CXAvailabilityKind, andCXPrintingPolicyPropertyto match current clang headers, including newer completion flags and contexts and corrected enum symbol names. - Fix the signedness of libclang predicate bindings for dynamic-call, variable-storage, include-guard, and source-location equality checks to match current headers.
- Fix
CXIdxEntityRefInfo[:role]to use an integer bitmask so single-role indexing references do not get mis-decoded as enum symbols and crash role extraction. - Fix
FFI::Clang::Cursor#overriddensuse-after-free: extractOverriddenCursorsclass that owns the buffer via AutoPointer and disposes it on GC instead of immediately after iteration. - Fix
FFI::Clang::Diagnostic#childrendouble-free on repeated calls: extractDiagnosticSetclass that caches child diagnostics so each is disposed exactly once. - Fix
FFI::Clang::Cursor#ancestors_by_kindto walk the full semantic parent chain instead of only checking the immediate parent. - Remove bogus
offsetattr_reader fromclass FFI::Clang::PresumedLocation—clang_getPresumedLocationdoes not return an offset.
New APIs
- Cursor:
binary_operator_kind(clang 17+),brief_comment_text,cxx_manglings,evaluate,external_symbol,function_inlined?,has_attrs?,has_external_storage?,has_global_storage?,inline_namespace?,invalid_declaration?,macro_builtin?,macro_function_like?,mangling,num_template_arguments,offset_of_base(clang 21+),offset_of_field,reference_name_range,spelling_name_range,storage_class,template_argument_kind,template_argument_type,template_argument_unsigned_value,template_argument_value,tls_kind,unary_operator_kind(clang 17+),var_decl_initializer,visibility. - Cursor class methods:
binary_operator_kind_spelling(clang 17+),unary_operator_kind_spelling(clang 17+). - CodeCompletion::FixIt: New class representing a fix-it required before a completion can be applied.
- CodeCompletion::Result:
fix_its,num_fix_its. - CursorSet: New class with
include?andinsertfor fast cursor membership checks. - Diagnostic:
category,category_id,children,disable_option,enable_option. - Diagnostic class methods:
default_display_opts. - DiagnosticSet: New enumerable class returned by
Diagnostic#children. - EvalResult: New class for compile-time constant evaluation —
as_double,as_int,as_long_long,as_str,as_unsigned,kind,unsigned_int?. - File:
==,contents,find_includes,real_path_name,skipped_ranges. - Index:
create_translation_unit2,create_translation_unit_from_source_file,create_action,global_options,global_options=,index_source_file,index_source_file_with_invocation,index_translation_unit,invocation_emission_path=, keyword-configurablenew(clang 17+) backed byCXChoiceandCXIndexOptions,parse_translation_unit_with_invocation. - IndexAction: New wrapper for libclang's higher-level indexing callbacks with
index_source_file,index_source_file_with_invocation, andindex_translation_unit. - SourceLocation:
<=>(viaComparable; usesclang_isBeforeInTranslationUnitfor ordering). - StringSet: New enumerable wrapper for libclang
CXStringSetresults. - Token:
from_location. - TranslationUnit:
all_skipped_ranges,skipped_ranges,suspend,target_pointer_width,target_triple. - Type:
address_space,fully_qualified_name(clang 21+),modified_type,nullability,pretty_printed(clang 21+),transparent_tag_typedef?,typedef_name,unqualified_type(clang 16+),value_type,visit_base_classes(clang 21+),visit_fields,visit_methods(clang 21+).
v0.14.0
- Helper method that returns a cursor's
FFI::Clang::Cursor#qualified_display_name. - Add release notes and documentation tooling.
- Modernize code and achieve 100% documentation coverage.
- Update minimum Ruby version to 3.2.
v0.13.0
- Add support for
clang_Type_getNamedType. (#90) - Try clang v18 + add Ruby v3.4 to test matrix. (#91)
v0.12.0
- Prefer
LIBCLANGandLLVM_CONFIGoverrides over Xcode. (#88)
v0.11.0
- Restore
visit_childrenmethod. Fixes #82. (#84) - Expose Clang's exception specification API. (#87)
- Support iterating over
Type::Functionargs and exposeLib.get_non_reference_type. (#85) - Fix qualified name. (#83)
- Update clang version. (#86)
v0.10.0
- Expose libclang's anonymous methods. (#79)
- Use Enumerable. (#80)
- Split
FFI::Clang::Typeinto a number of more cohesive subclasses inheriting fromFFI::Clang::Types::Type. (#81)
v0.9.0
- Remove duplicate mapping of
clang_getEnumDeclIntegerType. (#67) - Update bitmask options based on enums to always be an array of symbols. (#69)
- Add support for
parse_translation_unit2API. (#70) - Cursor improvements, Type improvements, Printing support. (#72)
- Fix finalizer exception in
FFI::Clang::CodeCompletion::Results. (#74) - Fix Clang 16 compatibility. (#76)
- Cursor location methods. (#78)
v0.8.0
- Modernize gem. (#58)
- Test on clang 5.0+. (#59)
- Fix
CXCursor_TranslationUnitenum value to 350. (#61) - Add
Cursor#hashandCursor#eql?. (#62) - Set
cursor_translation_unitenum value based on the Clang version. (#64) - Add various C++ introspection methods. (#66)
v0.7.0
- Fix incorrect return type of
clang_getTranslationUnitSpelling. - Fix
compilation_database_spec. - Fix libclang lookup for Xcode.
- Fix warning on class re-definition.
- Update cursor kinds.
- Find
libclang.dllunder Windows. - Allow retrieval of list of references from a Cursor.
- Implement libclang
findReferencesInFilefunctionality. - Allow
TranslationUnit#fileto return the main file.
v0.6.0
- Add missing translation unit parse flags.
v0.5.0
- Modernize code base, Clang v3.4+ only.
- Get text from
SourceRange. - Integrate
find_*intoCursor. - Test case for method calls inside classes. (#36)
v0.3.0
- Find and use
llvm-config. (#38) - Recognize Xcode 7.
- Add functions needed by RoboVM's bro-gen script.
v0.2.1
- Add inclusions support. (#32)
- Update unit tests for RSpec 3.
- Add
CompilationDatabase. (#27) - Only use
.dylibon Darwin. (#29)
v0.2.0
- Add clang version string APIs.
- Add cursor functions (except Objective-C). (#9)
- Add type kind and cursor kind enums. (#8)
- Add
TranslationUnitreference toCursorandType. (#11) - Multi-version libclang testing via Travis. (#10)
v0.1.3
- Add
CXTypesupport. (#5) - Correct camelCase
displayNametodisplay_name.
v0.1.2
- Initial support for source comments. (#4)
- Use different classes for comment types.
v0.1.1
- Support unsaved files. (#3)
- Add
Cursorvisitor function taking a block. - Add null cursor and
clang_is*functions. - Add
SourceLocationfrom diagnostic.
v0.1.0
- Initial release.
- FFI bindings for libclang Index, TranslationUnit, Diagnostic, SourceLocation.