Surface macro and inclusion-directive preprocessing API#812
Merged
tannergooding merged 1 commit intoJul 17, 2026
Merged
Conversation
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>
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.
Surfaces the v22 macro and inclusion-directive preprocessing bridges through the managed API, continuing the onboarding of the newly-reachable libClangSharp surface.
MacroDefinitionRecordnow exposes the underlyingMacroInfo:IsVariadic/IsC99Varargs/IsGNUVarargs,NumParameters/NumTokens, and theParameterNames/Tokenslists.InclusionDirectivenow exposesKind(CX_InclusionDirectiveKind) andWasInQuotes.The shared
CreateTranslationUnittest harness gained an optionaltranslationUnitFlagsparameter so preprocessing tests can requestCXTranslationUnit_DetailedPreprocessingRecord-- without it, macro/inclusion cursors aren't produced.MacroTokenKindis intentionally left unwrapped: it returns clang's internaltok::TokenKind, an unstable enum with no managed mapping.Because
MacroDefinitionRecordholds only the identifier, theMacroInforoute resolves the current active definition via thePreprocessor-- a#undef'd or redefined macro yields its last active definition.Note
Authored with Copilot.