From 80e66a05b6fad7d5f0ef71d5e0a74ce5ddc157a5 Mon Sep 17 00:00:00 2001 From: Louis Dionne Date: Tue, 22 Mar 2022 10:58:24 -0400 Subject: [PATCH] [clang][NFC] Refactor logic for picking standard library on Apple Flip the logic around: always default to libc++ except on older platforms, instead of defaulting to libstdc++ except on newer platforms. Since roughly all supported platforms use libc++ now, it makes more sense to make that the default, and allows the removal of some downstream diff. Differential Revision: https://reviews.llvm.org/D122232 --- clang/lib/Driver/ToolChains/Darwin.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/clang/lib/Driver/ToolChains/Darwin.cpp b/clang/lib/Driver/ToolChains/Darwin.cpp index 47eb14f..9f0eeea 100644 --- a/clang/lib/Driver/ToolChains/Darwin.cpp +++ b/clang/lib/Driver/ToolChains/Darwin.cpp @@ -869,13 +869,13 @@ types::ID MachO::LookupTypeForExtension(StringRef Ext) const { bool MachO::HasNativeLLVMSupport() const { return true; } ToolChain::CXXStdlibType Darwin::GetDefaultCXXStdlibType() const { - // Default to use libc++ on OS X 10.9+ and iOS 7+. - if ((isTargetMacOSBased() && !isMacosxVersionLT(10, 9)) || - (isTargetIOSBased() && !isIPhoneOSVersionLT(7, 0)) || - isTargetWatchOSBased()) - return ToolChain::CST_Libcxx; + // Use libstdc++ on old targets (OSX < 10.9 and iOS < 7) + if ((isTargetMacOSBased() && isMacosxVersionLT(10, 9)) || + (isTargetIOSBased() && isIPhoneOSVersionLT(7, 0))) + return ToolChain::CST_Libstdcxx; - return ToolChain::CST_Libstdcxx; + // On all other targets, use libc++ + return ToolChain::CST_Libcxx; } /// Darwin provides an ARC runtime starting in MacOS X 10.7 and iOS 5.0. -- 2.7.4