Skip to content

Surface macro and inclusion-directive preprocessing API#812

Merged
tannergooding merged 1 commit into
dotnet:mainfrom
tannergooding:tannergooding-v22-macro-preprocessing
Jul 17, 2026
Merged

Surface macro and inclusion-directive preprocessing API#812
tannergooding merged 1 commit into
dotnet:mainfrom
tannergooding:tannergooding-v22-macro-preprocessing

Conversation

@tannergooding

Copy link
Copy Markdown
Member

Surfaces the v22 macro and inclusion-directive preprocessing bridges through the managed API, continuing the onboarding of the newly-reachable libClangSharp surface.

MacroDefinitionRecord now exposes the underlying MacroInfo: IsVariadic/IsC99Varargs/IsGNUVarargs, NumParameters/NumTokens, and the ParameterNames/Tokens lists.

InclusionDirective now exposes Kind (CX_InclusionDirectiveKind) and WasInQuotes.


The shared CreateTranslationUnit test harness gained an optional translationUnitFlags parameter so preprocessing tests can request CXTranslationUnit_DetailedPreprocessingRecord -- without it, macro/inclusion cursors aren't produced.

MacroTokenKind is intentionally left unwrapped: it returns clang's internal tok::TokenKind, an unstable enum with no managed mapping.

Because MacroDefinitionRecord holds only the identifier, the MacroInfo route resolves the current active definition via the Preprocessor -- a #undef'd or redefined macro yields its last active definition.

Note

Authored with Copilot.

Wires the MacroInfo and InclusionDirective cursor bridges through the mid-layer CXCursor accessors and surfaces them on MacroDefinitionRecord (varargs flags, parameter names, replacement tokens) and InclusionDirective (kind, was-in-quotes).

MacroTokenKind is intentionally left unwrapped -- it returns clang's internal tok::TokenKind, an unstable enum with no managed mapping.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@tannergooding
tannergooding merged commit c974532 into dotnet:main Jul 17, 2026
12 checks passed
@tannergooding
tannergooding deleted the tannergooding-v22-macro-preprocessing branch July 17, 2026 04:39
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