Registry Mirror
Skip to content

Conversation

@tannergooding

Copy link
Copy Markdown
Member

A managed-only follow-up to #794 that surfaces additional Clang C++ AST API on the high-level managed layer (sources/ClangSharp/) using only interop bridges already present in the released package. No sources/libClangSharp/ changes. Every addition mirrors clang 21.1.8 (llvmorg-21.1.8) exactly.


Expr (Cursors/Exprs/Expr.cs)

Adds the remaining Ignore* accessors, composing single-step funcs that mirror IgnoreExpr.h and the composition in Expr.cpp:

  • IgnoreImpCasts — IgnoreExprNodes(IgnoreImplicitCastsSingleStep)
  • IgnoreCasts — IgnoreExprNodes(IgnoreCastsSingleStep)
  • IgnoreImplicitAsWritten — IgnoreExprNodes(IgnoreImplicitAsWrittenSingleStep)
  • IgnoreParenImpCasts — IgnoreExprNodes(IgnoreParensSingleStep, IgnoreImplicitCastsExtraSingleStep)
  • IgnoreParenCasts — IgnoreExprNodes(IgnoreParensSingleStep, IgnoreCastsSingleStep)
  • IgnoreParenLValueCasts — IgnoreExprNodes(IgnoreParensSingleStep, IgnoreLValueCastsSingleStep)
  • IgnoreParenBaseCasts — IgnoreExprNodes(IgnoreParensSingleStep, IgnoreBaseCastsSingleStep)

Adds the matching single-step funcs and a two-func IgnoreExprNodes overload that applies fn1 then fn2 per fixed-point step (mirroring detail::IgnoreExprNodesImpl).

LambdaExpr (Cursors/Exprs/LambdaExpr.cs)

  • CallOperator — mirrors LambdaExpr::getCallOperator() (getLambdaClass()->getLambdaCallOperator()). The released Cursor_getLambdaCallOperator dispatches on the closure CXXRecordDecl, not the LambdaExpr cursor, so this routes through Type.AsCXXRecordDecl.
  • IsMutable — mirrors LambdaExpr::isMutable() (!getCallOperator()->isConst()).

CXXRewrittenBinaryOperator (Cursors/Exprs/CXXRewrittenBinaryOperator.cs)

  • IsReversed — mirrors CXXRewrittenBinaryOperator::isReversed(), via a new CXCursor.IsReversed interop helper over the already-released clangsharp_Cursor_getIsReversed bridge.

Type (Types/Type.cs)

  • IsCharType — mirrors Type::isCharType() (BuiltinType of Char_U/UChar/Char_S/SChar).
  • IsMatrixType — mirrors Type::isMatrixType() (CanonicalType is MatrixType).

MemberPointerType (Types/MemberPointerType.cs)

  • IsMemberFunctionPointer — mirrors MemberPointerType::isMemberFunctionPointer() (PointeeType->isFunctionProtoType()).
  • IsMemberDataPointer — mirrors MemberPointerType::isMemberDataPointer() (negation).

Tests

  • New ExprTest.cs covering LambdaExpr.CallOperator/IsMutable, the Ignore* family, and reversed vs. spaceship-rewritten CXXRewrittenBinaryOperator.IsReversed (-std=c++20).
  • New TypeTest.cs cases for IsCharType, IsMatrixType (-fenable-matrix), and IsMemberFunctionPointer/IsMemberDataPointer.

Deferred to a native change

  • Subtle multi-category Type predicates (isScalarType, isArithmeticType, isFloatingType, isRealFloatingType, isAggregateType, isObjectType, hasPointerRepresentation, hasIntegerRepresentation, hasFloatingRepresentation) — spec-faithfulness needs data not cleanly available managed-side.
  • LambdaExpr.CaptureDefault — getLambdaCaptureDefault isn't in the released package.
  • Expr.IgnoreParenNoopCasts — requires ASTContext.
  • The transparent-PredefinedExpr sub-step of IgnoreParensSingleStep — the released Cursor_getIsTransparent only covers TypedefNameDecl/InitListExpr, not PredefinedExpr::isTransparent(). The existing shipped IgnoreParens already omits it; the new IgnoreParen* accessors reuse the same single-step and inherit that one pre-existing divergence.

Add the remaining faithful Expr Ignore* accessors (IgnoreImpCasts, IgnoreCasts, IgnoreImplicitAsWritten, IgnoreParenImpCasts, IgnoreParenCasts, IgnoreParenLValueCasts, IgnoreParenBaseCasts), surface LambdaExpr.CallOperator/IsMutable, add CXXRewrittenBinaryOperator.IsReversed with a CXCursor.IsReversed bridge, and add Type.IsCharType/IsMatrixType plus MemberPointerType.IsMemberFunctionPointer/IsMemberDataPointer.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@tannergooding
tannergooding merged commit ed68e21 into dotnet:main Jul 15, 2026
12 checks passed
@tannergooding
tannergooding deleted the tannergooding-managed-ignore-lambda-isreversed branch July 15, 2026 20:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant