aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Driver/Tools.cpp
diff options
context:
space:
mode:
authorFilipe Cabecinhas <me@filcab.net>2015-01-29 23:56:43 +0000
committerFilipe Cabecinhas <me@filcab.net>2015-01-29 23:56:43 +0000
commit28f353c7d0d31fbaf6176704cd37001086b94a6e (patch)
treea0b9609b903b81abf54871df7c497f72cf08950d /clang/lib/Driver/Tools.cpp
parentfbd9fbababafc51d1b275bbd286966f6d9dda3a4 (diff)
downloadllvm-28f353c7d0d31fbaf6176704cd37001086b94a6e.zip
llvm-28f353c7d0d31fbaf6176704cd37001086b94a6e.tar.gz
llvm-28f353c7d0d31fbaf6176704cd37001086b94a6e.tar.bz2
Add some more PS4 driver settings related to rtti and exceptions.
Summary: The PS4 defaults to -fno-rtti, and has to have rtti enabled when enabling exceptions. This commit makes clang add the -fno-rtti by default on the PS4, unless -frtti was passed in. It also diagnoses misuses for the PS4: - Exceptions need rtti. Warn and enable rtti if no rtti flag was passed, error if -fno-rtti was passed. I also added a more general warning for when -fno-rtti is the default (currently it's only on the PS4) and the vptr sanitizer is on. Fixed a few tests, due to different flag order when passing cc1 arguments. Reviewers: chandlerc Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D7250 llvm-svn: 227518
Diffstat (limited to 'clang/lib/Driver/Tools.cpp')
-rw-r--r--clang/lib/Driver/Tools.cpp46
1 files changed, 37 insertions, 9 deletions
diff --git a/clang/lib/Driver/Tools.cpp b/clang/lib/Driver/Tools.cpp
index 2258f69..91cf841 100644
--- a/clang/lib/Driver/Tools.cpp
+++ b/clang/lib/Driver/Tools.cpp
@@ -3956,20 +3956,48 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
false))
CmdArgs.push_back("-fno-elide-constructors");
- // -frtti is default.
- if (!Args.hasFlag(options::OPT_frtti, options::OPT_fno_rtti) ||
+ // -frtti is default, except for the PS4 CPU.
+ if (!Args.hasFlag(options::OPT_frtti, options::OPT_fno_rtti,
+ !Triple.isPS4CPU()) ||
KernelOrKext) {
- CmdArgs.push_back("-fno-rtti");
+ bool RTTIEnabled = false;
+ Arg *NoRTTIArg = Args.getLastArg(
+ options::OPT_mkernel, options::OPT_fapple_kext, options::OPT_fno_rtti);
+
+ // PS4 requires rtti when exceptions are enabled. If -fno-rtti was
+ // explicitly passed, error out. Otherwise enable rtti and emit a
+ // warning.
+ if (Triple.isPS4CPU()) {
+ if (Arg *A = Args.getLastArg(options::OPT_fcxx_exceptions,
+ options::OPT_fexceptions)) {
+ if (NoRTTIArg)
+ D.Diag(diag::err_drv_argument_not_allowed_with)
+ << NoRTTIArg->getAsString(Args) << A->getAsString(Args);
+ else {
+ RTTIEnabled = true;
+ D.Diag(diag::warn_drv_enabling_rtti_with_exceptions);
+ }
+ }
+ }
// -fno-rtti cannot usefully be combined with -fsanitize=vptr.
if (Sanitize.sanitizesVptr()) {
- std::string NoRttiArg =
- Args.getLastArg(options::OPT_mkernel,
- options::OPT_fapple_kext,
- options::OPT_fno_rtti)->getAsString(Args);
- D.Diag(diag::err_drv_argument_not_allowed_with)
- << "-fsanitize=vptr" << NoRttiArg;
+ // If rtti was explicitly disabled and the vptr sanitizer is on, error
+ // out. Otherwise, warn that vptr will be disabled unless -frtti is
+ // passed.
+ if (NoRTTIArg) {
+ D.Diag(diag::err_drv_argument_not_allowed_with)
+ << "-fsanitize=vptr" << NoRTTIArg->getAsString(Args);
+ } else {
+ D.Diag(diag::warn_drv_disabling_vptr_no_rtti_default);
+ // All sanitizer switches have been pushed. This -fno-sanitize
+ // will override any -fsanitize={vptr,undefined} passed before it.
+ CmdArgs.push_back("-fno-sanitize=vptr");
+ }
}
+
+ if (!RTTIEnabled)
+ CmdArgs.push_back("-fno-rtti");
}
// -fshort-enums=0 is default for all architectures except Hexagon.