Skip to content

Commit 0311223

Browse files
authored
ClangImporter: work around the inability to adjust the Darwin overlay (#82213)
Explicitly carve out `_stdio.stdin`, `_stdio.stdout`, `_stdio.stderr` as unaliased as the macros are explicitly imported through the `_stdio` overlay.
1 parent 270f56a commit 0311223

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

lib/ClangImporter/ImportMacro.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,12 @@ namespace {
377377
ValueDecl *importDeclAlias(ClangImporter::Implementation &clang,
378378
swift::DeclContext *DC, const clang::ValueDecl *D,
379379
Identifier alias) {
380+
if (DC->getASTContext().LangOpts.Target.isOSDarwin() &&
381+
DC->getParentModule()->getName().str() == StringRef("_stdio") &&
382+
llvm::any_of(llvm::ArrayRef<StringRef>{"stdin", "stdout", "stderr"},
383+
[alias = alias.str()](StringRef Id) { return alias == Id; }))
384+
return nullptr;
385+
380386
// Variadic functions cannot be imported into Swift.
381387
// FIXME(compnerd) emit a diagnostic for the missing diagnostic.
382388
if (const auto *FD = dyn_cast<clang::FunctionDecl>(D))
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// RUN: %target-typecheck-verify-swift %s
2+
// REQUIRES: VENDOR=apple
3+
4+
import var Darwin.stderr

0 commit comments

Comments
 (0)