summaryrefslogtreecommitdiffstats
path: root/clang/lib/Driver/ToolChains/Darwin.cpp
diff options
context:
space:
mode:
authorAkira Hatanaka <ahatanaka@apple.com>2017-06-29 18:48:40 +0000
committerAkira Hatanaka <ahatanaka@apple.com>2017-06-29 18:48:40 +0000
commitcae83f78aa28f40c023892b5a625a55fda12c1d9 (patch)
treef2d703de52613229bea8b04563eb9768bceb1468 /clang/lib/Driver/ToolChains/Darwin.cpp
parente9e5c4f975223de3c368773b77e16f476ede9ac2 (diff)
downloadbcm5719-llvm-cae83f78aa28f40c023892b5a625a55fda12c1d9.tar.gz
bcm5719-llvm-cae83f78aa28f40c023892b5a625a55fda12c1d9.zip
[Sema] Issue diagnostics if a new/delete expression generates a call to
a c++17 aligned allocation/deallocation function that is unavailable in the standard library on Apple platforms. The aligned functions are implemented only in the following versions or later versions of the OSes, so clang issues diagnostics if the deployment target being targeted is older than these: macosx: 10.13 ios: 11.0 tvos: 11.0 watchos: 4.0 The diagnostics are issued whenever the aligned functions are selected except when the selected function has a definition in the same file. If there is a user-defined function available somewhere else, option -Wno-aligned-allocation-unavailable can be used to silence the diagnostics. rdar://problem/32664169 Differential Revision: https://reviews.llvm.org/D34574 llvm-svn: 306722
Diffstat (limited to 'clang/lib/Driver/ToolChains/Darwin.cpp')
-rw-r--r--clang/lib/Driver/ToolChains/Darwin.cpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/clang/lib/Driver/ToolChains/Darwin.cpp b/clang/lib/Driver/ToolChains/Darwin.cpp
index e41b50c40b2..bfe685e70df 100644
--- a/clang/lib/Driver/ToolChains/Darwin.cpp
+++ b/clang/lib/Driver/ToolChains/Darwin.cpp
@@ -1667,6 +1667,27 @@ void MachO::AddLinkRuntimeLibArgs(const ArgList &Args,
AddLinkRuntimeLib(Args, CmdArgs, CompilerRT, false, true);
}
+bool Darwin::isAlignedAllocationUnavailable() const {
+ switch (TargetPlatform) {
+ case MacOS: // Earlier than 10.13.
+ return TargetVersion < VersionTuple(10U, 13U, 0U);
+ case IPhoneOS:
+ case IPhoneOSSimulator:
+ case TvOS:
+ case TvOSSimulator: // Earlier than 11.0.
+ return TargetVersion < VersionTuple(11U, 0U, 0U);
+ case WatchOS:
+ case WatchOSSimulator: // Earlier than 4.0.
+ return TargetVersion < VersionTuple(4U, 0U, 0U);
+ }
+}
+
+void Darwin::addClangTargetOptions(const llvm::opt::ArgList &DriverArgs,
+ llvm::opt::ArgStringList &CC1Args) const {
+ if (isAlignedAllocationUnavailable())
+ CC1Args.push_back("-faligned-alloc-unavailable");
+}
+
DerivedArgList *
Darwin::TranslateArgs(const DerivedArgList &Args, StringRef BoundArch,
Action::OffloadKind DeviceOffloadKind) const {
OpenPOWER on IntegriCloud