Onboard ClangSharp to clang 22.1.8#805
Merged
tannergooding merged 17 commits intoJul 16, 2026
Merged
Conversation
Bump VersionPrefix to 22.1.8.0 (resetting the build portion for the new LLVM version), the clang.MajorVersion/MinorVersion resolver constants to 22.1, and the libClang/libClangSharp package pins to 22.1.8/22.1.8.2 to match the native packages. Point the README runtime-package example at 22.1.8. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Refresh the auto-generated clangsharp/*.cs P/Invoke layer against the 22.1.8 libClangSharp surface (CX_* enum reshape and the new bridge entry points), and add CXCursor_OMPFuseDirective to the clang-c CXCursorKind enum. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Update the attr/stmt/type-class spelling switches and Debug.Assert range markers for clang 22: drop the removed HLSLSV_*/Replaceable/TriviallyRelocatable and Elaborated/DependentTemplateSpecialization arms, add the new attr spellings, and rename the OMP loop-transformation markers to their canonical-loop-nest form. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
clang 22 removes the ElaboratedType and DependentTemplateSpecializationType Type classes (the keyword moved onto each TypeWithKeyword-derived type, and dependent template specializations fold into TemplateSpecializationType). Remove the two managed Type classes and their dead Create arms, and reconcile the Attr.Create switch with the v22 attr-kind set. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
The five ElaboratedType branches never match under clang 22 since the underlying RecordType/EnumType/TypedefType is now hit directly; golden baselines are unchanged, confirming the removal is output-neutral. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
clang 22 changed the type printer to spell an unnamed tag as `(unnamed at ...)`, dropping the tag keyword that older releases embedded (`(anonymous struct at ...)`). The keyword is still present as the elaborated prefix, so key off it to restore the historical, version-stable NativeTypeName spelling rather than leaking the new form. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Adjust TemplateNameTest for the v22 sugar chain (SpecT's underlying type is now the TemplateSpecializationType directly), drop the ElaboratedType desugar assertions from ObjectiveCTest, and bump the embedded GeneratedCode version to 22.1.8.0. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Make a fresh generator run reproduce the committed clangsharp interop bindings so ClangSharp self-hosts on clang 22. Several generator gaps had to be closed: - Escape type names that are only lowercase ASCII (e.g. `clang`, `config`) with `@` to avoid CS8981. Applied centrally to every `TypeDecl` name and tag-type reference in name resolution; config and remap lookups strip the implicit `@` first so a user's raw `name`/`name=value` still matches. - Preserve enumerator initializers that are a pure alias to (or `|` combination of) sibling enumerators, so range markers like `CX_DeclKind_FirstObjCImpl = CX_DeclKind_ObjCImplementation` stay symbolic instead of folding to a literal. - When a folded enum member's value equals a prior sibling, emit that sibling symbolically. This keeps `_Last`/`MaxSemantics` markers -- whose initializer is an opaque X-macro count rather than a `DeclRefExpr` -- readable (e.g. `CX_UTT_Last = CX_UTT_IsTypedResourceElementCompatible`). ---------- List the specific enums that mirror an excluded companion in GenerateClangSharp.rsp instead of folding everything with `*`. ---------- Fix the `CX_UETT_Last` off-by-one in libClangSharp: it kept clang's `-1` base (clang's `UnaryExprOrTypeTrait` has no `Invalid` sentinel) even though we prepend `CX_UETT_Invalid`, where-as `CX_TypeTrait` already uses `0`. `CX_UETT_Last` now lands on `CX_UETT_VectorElements` like the other trait `_Last` markers. Regenerate the affected clangsharp enums and add regression tests. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Wire clangsharp_Type_getKeyword, getDependence, and getAutoTypeKeyword through the CXType handle wrapper as Keyword, Dependence, and AutoTypeKeyword, mirroring the existing Type_get* accessor style. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
clang 22 reparented TagType, TypedefType, UsingType, UnresolvedUsingType, and TemplateSpecializationType under TypeWithKeyword, so the elaboration keyword is now observable on each; reparent them to match and surface it as TypeWithKeyword.Keyword. Add the Type dependence predicates (IsDependentType, IsInstantiationDependentType, IsVariablyModifiedType, ContainsUnexpandedParameterPack, ContainsErrors) over the consolidated Dependence flags, and AutoType.Keyword. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
…state A generation aborted mid-visit left `_outputBuilder` (and related builder state) dangling, tripping the `_outputBuilder is null` assert from the finalizer during GC teardown and crashing the test host, which masked the underlying error and aborted the entire run. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
…clang 22 Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
The win-arm64 libClangSharp 22.1.8.2 prebuilt ships broken clangsharp shims that access-violate and crash the test host. See dotnet#806. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Port the three Stmt kinds libclang added in clang 22 (DeferStmt, MatrixSingleSubscriptExpr, OMPFuseDirective) into MakeCXCursor, and bump the "Ported from" stamps on the mirrored libclang files to llvmorg-22.1.8. The remaining files are byte-identical to the 22.1.8 upstream sources. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
The win-arm64 libClangSharp 22.1.8.2 native returns invalid template names and access-violates in the cursor/type shims, so tests that read a TemplateName cannot be validated there. Skip TemplateNameTest and DependentTemplateBaseTest via a shared SkipUntilNativeRebuild helper on the interop and generator test bases until the native is rebuilt. See dotnet#806. Also drop the speculative dependent-base fallback added while diagnosing this; the anonymous-name fix is retained. 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.
Onboards the managed and generator layers to clang 22.1.8, regenerates the self-hosted interop, and surfaces the reshaped v22
TypeAPI.clang 22 removed the
ElaboratedTypeandDependentTemplateSpecializationTypeTypeclasses. The elaborated-type keyword moved directly onto everyTypeWithKeyword-derived type, and the dependent template-specialization case folded intoTemplateSpecializationTypevia a dependentTemplateName. This bumps the managed version and interop headers to 22.1.8, regeneratesClangSharp.Interopagainst the 22.1.8 native surface, and reconciles the managed AST with the removals.Managed AST port. Deletes
ElaboratedType/DependentTemplateSpecializationTypeand theirType.Createarms, and reparentsTagType,TypedefType,UsingType,UnresolvedUsingType, andTemplateSpecializationTypeunderTypeWithKeywordto match the clang 22 hierarchy (joining the already-parentedDependentNameType). The elaboration keyword is now observable on each viaTypeWithKeyword.Keyword, and a plain tag/typedef/using type correctly reportsCX_ETK_Nonerather than falling through toInvalid.Type keyword + dependence surface. Wires the reshaped v22 bridges through all three layers:
CXType.Keyword/Dependence/AutoTypeKeywordon the interop extension, and on the managed ASTTypeWithKeyword.Keyword,AutoType.Keyword, plus theTypedependence predicates (IsDependentType,IsInstantiationDependentType,IsVariablyModifiedType,ContainsUnexpandedParameterPack,ContainsErrors) over the consolidatedDependenceflags -- mirroring the existingExpr/TemplateArgumentdependence pattern.Generator. Removes the dead
ElaboratedTypehandling (the five branches never match under clang 22 since the underlyingRecordType/EnumType/TypedefTypeis hit directly; golden baselines are unchanged, confirming the removal is output-neutral), and normalizes the clang 22 unnamed-tag spelling back to the anonymous form the baselines expect.Self-hosting. The generator once again reproduces the committed
ClangSharp.Interopbindings byte-for-byte (bootstrap), except the two intentionally hand-curatedCX_TemplateArgument/CX_TemplateArgumentLocstructs.Out of scope / follow-up: the 22.1.8 regen brought a large batch of newly-available
clangsharp_*bridges into the raw interop that the mid/high layers don't yet expose (LambdaExpr cluster,CXXRecordDeclstructural predicates,Exprvalue/object kind, constexpr family, empty-shell Stmt/Expr classes,FunctionProtoTypeexception spec). These were previously blocked on a native rebuild and are now unblocked managed-side; they'll land as separate focused PRs.Verified:
dotnet build -c Release0 warnings; full suite green (4077 generator golden-file + 37 CLI + 75 interop, incl. newTypeTestcoverage for the keyword/dependence accessors).Note
Authored with Copilot.