Disable SjLj exceptions for watchOS
llvm-svn: 251709
diff --git a/clang/lib/Driver/ToolChains.cpp b/clang/lib/Driver/ToolChains.cpp
index b65c5c1..43a8ff6 100644
--- a/clang/lib/Driver/ToolChains.cpp
+++ b/clang/lib/Driver/ToolChains.cpp
@@ -1037,10 +1037,18 @@
return false;
}
-bool Darwin::UseSjLjExceptions() const {
+bool Darwin::UseSjLjExceptions(const ArgList &Args) const {
// Darwin uses SjLj exceptions on ARM.
- return (getTriple().getArch() == llvm::Triple::arm ||
- getTriple().getArch() == llvm::Triple::thumb);
+ if (getTriple().getArch() != llvm::Triple::arm &&
+ getTriple().getArch() != llvm::Triple::thumb)
+ return false;
+
+ // We can't check directly for watchOS here. ComputeLLVMTriple only
+ // fills in the ArchName correctly.
+ llvm::Triple Triple(ComputeLLVMTriple(Args));
+ return !(Triple.getArchName() == "armv7k" ||
+ Triple.getArchName() == "thumbv7k");
+
}
bool MachO::isPICDefault() const { return true; }
@@ -2952,7 +2960,7 @@
Tool *FreeBSD::buildLinker() const { return new tools::freebsd::Linker(*this); }
-bool FreeBSD::UseSjLjExceptions() const {
+bool FreeBSD::UseSjLjExceptions(const ArgList &Args) const {
// FreeBSD uses SjLj exceptions on ARM oabi.
switch (getTriple().getEnvironment()) {
case llvm::Triple::GNUEABIHF:
diff --git a/clang/lib/Driver/ToolChains.h b/clang/lib/Driver/ToolChains.h
index d884032..7743378 100644
--- a/clang/lib/Driver/ToolChains.h
+++ b/clang/lib/Driver/ToolChains.h
@@ -339,7 +339,9 @@
bool UseDwarfDebugFlags() const override;
- bool UseSjLjExceptions() const override { return false; }
+ bool UseSjLjExceptions(const llvm::opt::ArgList &Args) const override {
+ return false;
+ }
/// }
};
@@ -528,7 +530,7 @@
void CheckObjCARC() const override;
- bool UseSjLjExceptions() const override;
+ bool UseSjLjExceptions(const llvm::opt::ArgList &Args) const override;
SanitizerMask getSupportedSanitizers() const override;
};
@@ -714,7 +716,7 @@
const llvm::opt::ArgList &DriverArgs,
llvm::opt::ArgStringList &CC1Args) const override;
- bool UseSjLjExceptions() const override;
+ bool UseSjLjExceptions(const llvm::opt::ArgList &Args) const override;
bool isPIEDefault() const override;
SanitizerMask getSupportedSanitizers() const override;
unsigned GetDefaultDwarfVersion() const override { return 2; }
diff --git a/clang/lib/Driver/Tools.cpp b/clang/lib/Driver/Tools.cpp
index 42a1685..e72e4bd 100644
--- a/clang/lib/Driver/Tools.cpp
+++ b/clang/lib/Driver/Tools.cpp
@@ -4824,7 +4824,7 @@
addExceptionArgs(Args, InputType, getToolChain(), KernelOrKext, objcRuntime,
CmdArgs);
- if (getToolChain().UseSjLjExceptions())
+ if (getToolChain().UseSjLjExceptions(Args))
CmdArgs.push_back("-fsjlj-exceptions");
// C++ "sane" operator new.