@@ -3197,19 +3197,30 @@ namespace {
31973197 // presence in the C++ standard library will cause overloading
31983198 // ambiguities or other type checking errors in Swift.
31993199 auto isAlternativeCStdlibFunctionFromTextualHeader =
3200- [](const clang::FunctionDecl *d) -> bool {
3200+ [this ](const clang::FunctionDecl *d) -> bool {
32013201 // stdlib.h might be a textual header in libc++'s module map.
32023202 // in this case, check for known ambiguous functions by their name
32033203 // instead of checking if they come from the `std` module.
32043204 if (!d->getDeclName ().isIdentifier ())
32053205 return false ;
3206- return d->getName () == " abs" || d->getName () == " div" ;
3206+ if (d->getName () == " abs" || d->getName () == " div" )
3207+ return true ;
3208+ if (Impl.SwiftContext .LangOpts .Target .isOSDarwin ())
3209+ return d->getName () == " strstr" || d->getName () == " sin" ||
3210+ d->getName () == " cos" || d->getName () == " exit" ;
3211+ return false ;
32073212 };
3208- if (decl->getOwningModule () &&
3209- (decl->getOwningModule ()
3210- ->getTopLevelModule ()
3211- ->getFullModuleName () == " std" ||
3212- isAlternativeCStdlibFunctionFromTextualHeader (decl))) {
3213+ auto topLevelModuleEq =
3214+ [](const clang::FunctionDecl *d, StringRef n) -> bool {
3215+ return d->getOwningModule () &&
3216+ d->getOwningModule ()
3217+ ->getTopLevelModule ()
3218+ ->getFullModuleName () == n;
3219+ };
3220+ if (topLevelModuleEq (decl, " std" )) {
3221+ if (isAlternativeCStdlibFunctionFromTextualHeader (decl)) {
3222+ return nullptr ;
3223+ }
32133224 auto filename =
32143225 Impl.getClangPreprocessor ().getSourceManager ().getFilename (
32153226 decl->getLocation ());
@@ -3218,6 +3229,13 @@ namespace {
32183229 return nullptr ;
32193230 }
32203231 }
3232+ // Use the exit function from _SwiftConcurrency.h as it is platform
3233+ // agnostic.
3234+ if ((topLevelModuleEq (decl, " Darwin" ) ||
3235+ topLevelModuleEq (decl, " SwiftGlibc" )) &&
3236+ decl->getDeclName ().isIdentifier () && decl->getName () == " exit" ) {
3237+ return nullptr ;
3238+ }
32213239 }
32223240
32233241 auto dc =
0 commit comments