summaryrefslogtreecommitdiffstats
path: root/clang/lib/Driver/ToolChains
diff options
context:
space:
mode:
authorMartell Malone <martellmalone@gmail.com>2017-11-29 06:25:13 +0000
committerMartell Malone <martellmalone@gmail.com>2017-11-29 06:25:13 +0000
commit390cfcb0b1df73b7b2a13e02f63dff46e8fe09cd (patch)
tree14bb962e9997aafccb817476363088840ff91266 /clang/lib/Driver/ToolChains
parent1c3b62282089e57480e80e55dd133f573f48dc30 (diff)
downloadbcm5719-llvm-390cfcb0b1df73b7b2a13e02f63dff46e8fe09cd.tar.gz
bcm5719-llvm-390cfcb0b1df73b7b2a13e02f63dff46e8fe09cd.zip
Toolchain: Normalize dwarf, sjlj and seh eh
adds -fseh-exceptions and -fdwarf-exceptions flags clang will check if the user has specified an exception model flag, in the absense of specifying the exception model clang will then check the driver default and append the model flag for that target to cc1 clang cc1 assumes dwarf is the default if none is passed and -fno-exceptions has a higher priority then specifying the model move __SEH__ macro definitions out of Targets into InitPreprocessor behind the -fseh-exceptions flag move __ARM_DWARF_EH__ macrodefinitions out of verious targets and into InitPreprocessor behind the -fdwarf-exceptions flag and arm|thumb check remove unused USESEHExceptions from the MinGW Driver fold USESjLjExceptions into a new GetExceptionModel function that gives the toolchain classes more flexibility with eh models Reviewers: rnk, mstorsjo Differential Revision: https://reviews.llvm.org/D39673 llvm-svn: 319294
Diffstat (limited to 'clang/lib/Driver/ToolChains')
-rw-r--r--clang/lib/Driver/ToolChains/Clang.cpp30
-rw-r--r--clang/lib/Driver/ToolChains/Darwin.cpp11
-rw-r--r--clang/lib/Driver/ToolChains/Darwin.h8
-rw-r--r--clang/lib/Driver/ToolChains/FreeBSD.cpp12
-rw-r--r--clang/lib/Driver/ToolChains/FreeBSD.h3
-rw-r--r--clang/lib/Driver/ToolChains/MinGW.cpp7
-rw-r--r--clang/lib/Driver/ToolChains/MinGW.h4
-rw-r--r--clang/lib/Driver/ToolChains/NetBSD.cpp8
-rw-r--r--clang/lib/Driver/ToolChains/NetBSD.h3
9 files changed, 66 insertions, 20 deletions
diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp
index d96664cf0be..1c90c6e9225 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -4166,9 +4166,33 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
addExceptionArgs(Args, InputType, getToolChain(), KernelOrKext, Runtime,
CmdArgs);
- if (Args.hasArg(options::OPT_fsjlj_exceptions) ||
- getToolChain().UseSjLjExceptions(Args))
- CmdArgs.push_back("-fsjlj-exceptions");
+ // Handle exception personalities
+ Arg *A = Args.getLastArg(options::OPT_fsjlj_exceptions,
+ options::OPT_fseh_exceptions,
+ options::OPT_fdwarf_exceptions);
+ if (A) {
+ const Option &Opt = A->getOption();
+ if (Opt.matches(options::OPT_fsjlj_exceptions))
+ CmdArgs.push_back("-fsjlj-exceptions");
+ if (Opt.matches(options::OPT_fseh_exceptions))
+ CmdArgs.push_back("-fseh-exceptions");
+ if (Opt.matches(options::OPT_fdwarf_exceptions))
+ CmdArgs.push_back("-fdwarf-exceptions");
+ } else {
+ switch(getToolChain().GetExceptionModel(Args)) {
+ default:
+ break;
+ case llvm::ExceptionHandling::DwarfCFI:
+ CmdArgs.push_back("-fdwarf-exceptions");
+ break;
+ case llvm::ExceptionHandling::SjLj:
+ CmdArgs.push_back("-fsjlj-exceptions");
+ break;
+ case llvm::ExceptionHandling::WinEH:
+ CmdArgs.push_back("-fseh-exceptions");
+ break;
+ }
+ }
// C++ "sane" operator new.
if (!Args.hasFlag(options::OPT_fassume_sane_operator_new,
diff --git a/clang/lib/Driver/ToolChains/Darwin.cpp b/clang/lib/Driver/ToolChains/Darwin.cpp
index 5dc8a91bcf1..7c401aa9dd5 100644
--- a/clang/lib/Driver/ToolChains/Darwin.cpp
+++ b/clang/lib/Driver/ToolChains/Darwin.cpp
@@ -1881,7 +1881,7 @@ bool MachO::IsUnwindTablesDefault(const ArgList &Args) const {
// Unwind tables are not emitted if -fno-exceptions is supplied (except when
// targeting x86_64).
return getArch() == llvm::Triple::x86_64 ||
- (!UseSjLjExceptions(Args) &&
+ (GetExceptionModel(Args) != llvm::ExceptionHandling::SjLj &&
Args.hasFlag(options::OPT_fexceptions, options::OPT_fno_exceptions,
true));
}
@@ -1892,15 +1892,18 @@ bool MachO::UseDwarfDebugFlags() const {
return false;
}
-bool Darwin::UseSjLjExceptions(const ArgList &Args) const {
+llvm::ExceptionHandling Darwin::GetExceptionModel(const ArgList &Args) const {
// Darwin uses SjLj exceptions on ARM.
if (getTriple().getArch() != llvm::Triple::arm &&
getTriple().getArch() != llvm::Triple::thumb)
- return false;
+ return llvm::ExceptionHandling::None;
// Only watchOS uses the new DWARF/Compact unwinding method.
llvm::Triple Triple(ComputeLLVMTriple(Args));
- return !Triple.isWatchABI();
+ if(Triple.isWatchABI())
+ return llvm::ExceptionHandling::DwarfCFI;
+
+ return llvm::ExceptionHandling::SjLj;
}
bool Darwin::SupportsEmbeddedBitcode() const {
diff --git a/clang/lib/Driver/ToolChains/Darwin.h b/clang/lib/Driver/ToolChains/Darwin.h
index 2b8477aa275..c861f172fe1 100644
--- a/clang/lib/Driver/ToolChains/Darwin.h
+++ b/clang/lib/Driver/ToolChains/Darwin.h
@@ -247,8 +247,9 @@ public:
bool UseDwarfDebugFlags() const override;
- bool UseSjLjExceptions(const llvm::opt::ArgList &Args) const override {
- return false;
+ llvm::ExceptionHandling
+ GetExceptionModel(const llvm::opt::ArgList &Args) const override {
+ return llvm::ExceptionHandling::None;
}
/// }
@@ -455,7 +456,8 @@ public:
void CheckObjCARC() const override;
- bool UseSjLjExceptions(const llvm::opt::ArgList &Args) const override;
+ llvm::ExceptionHandling GetExceptionModel(
+ const llvm::opt::ArgList &Args) const override;
bool SupportsEmbeddedBitcode() const override;
diff --git a/clang/lib/Driver/ToolChains/FreeBSD.cpp b/clang/lib/Driver/ToolChains/FreeBSD.cpp
index 2f066cf0cc8..025acf15117 100644
--- a/clang/lib/Driver/ToolChains/FreeBSD.cpp
+++ b/clang/lib/Driver/ToolChains/FreeBSD.cpp
@@ -359,17 +359,17 @@ Tool *FreeBSD::buildAssembler() const {
Tool *FreeBSD::buildLinker() const { return new tools::freebsd::Linker(*this); }
-bool FreeBSD::UseSjLjExceptions(const ArgList &Args) const {
+llvm::ExceptionHandling FreeBSD::GetExceptionModel(const ArgList &Args) const {
// FreeBSD uses SjLj exceptions on ARM oabi.
switch (getTriple().getEnvironment()) {
+ default:
+ if (getTriple().getArch() == llvm::Triple::arm ||
+ getTriple().getArch() == llvm::Triple::thumb)
+ return llvm::ExceptionHandling::SjLj;
case llvm::Triple::GNUEABIHF:
case llvm::Triple::GNUEABI:
case llvm::Triple::EABI:
- return false;
-
- default:
- return (getTriple().getArch() == llvm::Triple::arm ||
- getTriple().getArch() == llvm::Triple::thumb);
+ return llvm::ExceptionHandling::None;
}
}
diff --git a/clang/lib/Driver/ToolChains/FreeBSD.h b/clang/lib/Driver/ToolChains/FreeBSD.h
index 25e9df72bc8..2943e1cacfb 100644
--- a/clang/lib/Driver/ToolChains/FreeBSD.h
+++ b/clang/lib/Driver/ToolChains/FreeBSD.h
@@ -66,7 +66,8 @@ public:
void AddCXXStdlibLibArgs(const llvm::opt::ArgList &Args,
llvm::opt::ArgStringList &CmdArgs) const override;
- bool UseSjLjExceptions(const llvm::opt::ArgList &Args) const override;
+ llvm::ExceptionHandling GetExceptionModel(
+ 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/ToolChains/MinGW.cpp b/clang/lib/Driver/ToolChains/MinGW.cpp
index 79864eab83e..572ea803f2d 100644
--- a/clang/lib/Driver/ToolChains/MinGW.cpp
+++ b/clang/lib/Driver/ToolChains/MinGW.cpp
@@ -367,8 +367,11 @@ bool toolchains::MinGW::isPICDefaultForced() const {
return getArch() == llvm::Triple::x86_64;
}
-bool toolchains::MinGW::UseSEHExceptions() const {
- return getArch() == llvm::Triple::x86_64;
+llvm::ExceptionHandling
+toolchains::MinGW::GetExceptionModel(const ArgList &Args) const {
+ if (getArch() == llvm::Triple::x86_64)
+ return llvm::ExceptionHandling::WinEH;
+ return llvm::ExceptionHandling::DwarfCFI;
}
void toolchains::MinGW::AddCudaIncludeArgs(const ArgList &DriverArgs,
diff --git a/clang/lib/Driver/ToolChains/MinGW.h b/clang/lib/Driver/ToolChains/MinGW.h
index 9b3d7c553f1..f8dbcae6275 100644
--- a/clang/lib/Driver/ToolChains/MinGW.h
+++ b/clang/lib/Driver/ToolChains/MinGW.h
@@ -64,7 +64,9 @@ public:
bool isPICDefault() const override;
bool isPIEDefault() const override;
bool isPICDefaultForced() const override;
- bool UseSEHExceptions() const;
+
+ llvm::ExceptionHandling GetExceptionModel(
+ const llvm::opt::ArgList &Args) const override;
void
AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs,
diff --git a/clang/lib/Driver/ToolChains/NetBSD.cpp b/clang/lib/Driver/ToolChains/NetBSD.cpp
index 85bb69cfda0..c0a0808b377 100644
--- a/clang/lib/Driver/ToolChains/NetBSD.cpp
+++ b/clang/lib/Driver/ToolChains/NetBSD.cpp
@@ -416,6 +416,14 @@ void NetBSD::addLibStdCxxIncludePaths(const llvm::opt::ArgList &DriverArgs,
"", DriverArgs, CC1Args);
}
+llvm::ExceptionHandling NetBSD::GetExceptionModel(const ArgList &Args) const {
+ // NetBSD uses Dwarf exceptions on ARM.
+ if (getTriple().getArch() == llvm::Triple::arm ||
+ getTriple().getArch() == llvm::Triple::thumb)
+ return llvm::ExceptionHandling::DwarfCFI;
+ return llvm::ExceptionHandling::None;
+}
+
SanitizerMask NetBSD::getSupportedSanitizers() const {
const bool IsX86 = getTriple().getArch() == llvm::Triple::x86;
const bool IsX86_64 = getTriple().getArch() == llvm::Triple::x86_64;
diff --git a/clang/lib/Driver/ToolChains/NetBSD.h b/clang/lib/Driver/ToolChains/NetBSD.h
index 5163ff72d81..e98df72ce65 100644
--- a/clang/lib/Driver/ToolChains/NetBSD.h
+++ b/clang/lib/Driver/ToolChains/NetBSD.h
@@ -69,6 +69,9 @@ public:
return true;
}
+ llvm::ExceptionHandling GetExceptionModel(
+ const llvm::opt::ArgList &Args) const override;
+
SanitizerMask getSupportedSanitizers() const override;
protected:
OpenPOWER on IntegriCloud