Skip to content

Commit bd11926

Browse files
committed
[Swiftify] Adjust _SwiftifyImport invocation to align with the signature
of the macro in the currently laoded macro module Stdlib macros are shipped with the SDK, so we need to make sure that the way we invoke the macro matches the version of the macro in the SDK. This patch skips the `spanAvailability` parameter if it isn't present. There's no good way to test this, because we will always pick up the current macro in our llvm-lit test suite, but I've tested it manually. rdar://152278292
1 parent c0c7bf3 commit bd11926

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

lib/ClangImporter/ImportDecl.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9055,12 +9055,26 @@ class SwiftifyInfoPrinter {
90559055
}
90569056

90579057
void printAvailability() {
9058+
if (!hasMacroParameter("spanAvailability"))
9059+
return;
90589060
printSeparator();
90599061
out << "spanAvailability: ";
90609062
printAvailabilityOfType("Span");
90619063
}
90629064

90639065
private:
9066+
bool hasMacroParameter(StringRef ParamName) {
9067+
ValueDecl *D = getDecl("_SwiftifyImport");
9068+
auto *SwiftifyImportDecl = dyn_cast_or_null<MacroDecl>(D);
9069+
assert(SwiftifyImportDecl);
9070+
if (!SwiftifyImportDecl)
9071+
return false;
9072+
for (auto *Param : *SwiftifyImportDecl->parameterList)
9073+
if (Param->getArgumentName().str() == ParamName)
9074+
return true;
9075+
return false;
9076+
}
9077+
90649078
ValueDecl *getDecl(StringRef DeclName) {
90659079
SmallVector<ValueDecl *, 1> decls;
90669080
SwiftContext.lookupInSwiftModule(DeclName, decls);

stdlib/public/core/SwiftifyImport.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,4 +104,4 @@ public func _swiftifyOverrideLifetime<
104104
// TODO: Remove @_unsafeNonescapableResult. Instead, the unsafe dependence
105105
// should be expressed by a builtin that is hidden within the function body.
106106
dependent
107-
}
107+
}

0 commit comments

Comments
 (0)