mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Implement preamble macros to augment a function body
Implement type checking support for preamble macros, which expands the preamble macros and introduces them at the beginning of the function body prior to type checking. Ensure that the resulting function bodies type-check properly, including when composing multiple preamble macros and with a preamble macro applied to the body of a function that itself came from a body macro.
This commit is contained in:
@@ -1209,11 +1209,12 @@ llvm::Optional<MacroRole> SourceFile::getFulfilledMacroRole() const {
|
||||
}
|
||||
|
||||
SourceFile *SourceFile::getEnclosingSourceFile() const {
|
||||
auto macroExpansion = getMacroExpansion();
|
||||
if (!macroExpansion)
|
||||
if (Kind != SourceFileKind::MacroExpansion)
|
||||
return nullptr;
|
||||
|
||||
auto sourceLoc = macroExpansion.getStartLoc();
|
||||
auto genInfo =
|
||||
*getASTContext().SourceMgr.getGeneratedSourceInfo(*getBufferID());
|
||||
auto sourceLoc = genInfo.originalSourceRange.getStart();
|
||||
return getParentModule()->getSourceFileContainingLocation(sourceLoc);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user