[Macros] Pass a static build configuration to macro implementations #84580
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.
Implement support for creating a
StaticBuildConfiguration
fromLangOptions
. That static build configuration can be printed as JSON to standard output with the new-print-static-build-config
frontend option, and will be passed down to macro implementations so that can perform#if
-related evaluations based on the context in which the macro is expanded. To ensure completeness, reseat the existingCompilerBuildConfiguration
on top of the createdStaticBuildConfiguration
so all#if
-handling code in the compiler goes through it.There is a bit of code reshuffling here to establish another layer of Swift library between the C++ Basic and AST libraries. The code to form a
StaticBuildConfiguration
exists in this layer, so it can be used without an establishedASTContext
. TheASTContext
does, however, have the ability to build a cache theStaticBuildConfiguration
instance.Tracked by rdar://146868706