Port libClangSharp to the LLVM 22 Clang AST#785
Merged
tannergooding merged 1 commit intoJul 15, 2026
Conversation
Update sources/libClangSharp for the LLVM 21 -> 22 type-sugar refactor so it compiles and links against the 22.1.8 release: - ElaboratedType is removed; the elaboration keyword/qualifier and tag ownership moved onto TagType, so getOwnedTagDecl now uses TagType::isTagOwned()/getDecl() and the Elaborated CXType kind mapping is dropped. - InjectedClassNameType is now a TagType; recover the injected specialization via getCanonicalInjectedSpecializationType and getTemplateName/getTemplateArgs(ctx), which return the canonical injected type (22 no longer stores the as-written one). - DependentTemplateSpecializationType is folded into TemplateSpecializationType, so its template-argument branch is dropped and handled by the existing one. - UsingType::getFoundDecl is renamed to getDecl. Set CMAKE_MSVC_RUNTIME_LIBRARY to the static CRT so libClangSharp links against the official /MT LLVM release binaries without LNK2038. ---------- Move the regenerate-native detection/verification out of YAML into build.ps1|sh (--detectchanges/--verifypackages) so it is reproducible and testable locally, and thin the workflow down to glue around the scripts. Directory.Packages.props intentionally stays on the 21.1.8 consuming refs; the 22.1.8 native packages are published by this workflow first, then bumped in a follow-up. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Note
This PR body was drafted by Copilot.
Updates
sources/libClangSharpfor the LLVM 21 -> 22 type-sugar refactor so the native library compiles and links against the 22.1.8 release (#779 bumped the tracked version ahead of the C++ port, leaving theregenerate-nativelegs red).libClangSharp port
ElaboratedTypeis removed; the elaboration keyword/qualifier and tag ownership moved ontoTagType.clangsharp_Type_getOwnedTagDeclnow usesTagType::isTagOwned()/getDecl(), and theElaboratedCXTypekind mapping is dropped fromCXType.cpp.InjectedClassNameTypeis now aTagType. The injected specialization is recovered viagetCanonicalInjectedSpecializationType(ctx)(decl-level, the same replacement clang itself uses infindPartialSpecialization) and viagetCanonicalTemplateSpecializationType(None, getTemplateName(ctx), getTemplateArgs(ctx))(type-level, matching clang's ownClassTemplatePartialSpecializationDecl::getCanonicalInjectedSpecializationTypeconstruction).DependentTemplateSpecializationTypeis folded intoTemplateSpecializationType; its template-argument branch is dropped and handled by the existingTemplateSpecializationTypebranch.UsingType::getFoundDecl->getDecl(same underlyingUsingShadowDecl).One inherent behavior shift: the injected-specialization getters now return the canonical injected type -- LLVM 22 no longer stores the as-written one. Same template and injected args.
Build
CMakeLists.txt: setCMAKE_MSVC_RUNTIME_LIBRARYto the static CRT (/MT) so libClangSharp links against the official/MTLLVM release binaries withoutLNK2038. Bumpedcmake_minimum_required3.13 -> 3.15 so the runtime-library policy applies. Validated locally: compiles with 0 errors and linkslibClangSharp.dllagainst the real 22.1.8 release via a plain-DPATH_TO_LLVMinvocation.Detect refactor
Moves the
regenerate-nativechange-detection and package-version verification out of YAML intobuild.ps1/build.sh(--detectchanges/--verifypackages) so they're reproducible and testable locally, and thins the workflow down to glue around the scripts.Directory.Packages.propsintentionally stays on the21.1.8consuming refs soci.ymlrestore stays green -- the22.1.8native packages are published by this workflow first. A stacked follow-up then bumps the consuming refs, regenerates the managed bindings, and fixes theCX_TypeClassordinals (the LLVM 22TypeNodeschange removesElaborated/DependentTemplateSpecializationand reparentsInjectedClassName, shifting the ordinals thatclangsharp_Type_getTypeClassfeeds into the managed enum).