Index: cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td =================================================================== --- cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td +++ cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td @@ -266,9 +266,6 @@ InGroup>; def warn_debug_compression_unavailable : Warning<"cannot compress debug sections (zlib not installed)">, InGroup>; -def warn_drv_enabling_rtti_with_exceptions : Warning< - "implicitly enabling rtti for exception handling">, - InGroup>; def warn_drv_disabling_vptr_no_rtti_default : Warning< "implicitly disabling vptr sanitizer because rtti wasn't enabled">, InGroup; Index: cfe/trunk/include/clang/Driver/ToolChain.h =================================================================== --- cfe/trunk/include/clang/Driver/ToolChain.h +++ cfe/trunk/include/clang/Driver/ToolChain.h @@ -100,10 +100,8 @@ }; enum RTTIMode { - RM_EnabledExplicitly, - RM_EnabledImplicitly, - RM_DisabledExplicitly, - RM_DisabledImplicitly + RM_Enabled, + RM_Disabled, }; private: Index: cfe/trunk/lib/Driver/SanitizerArgs.cpp =================================================================== --- cfe/trunk/lib/Driver/SanitizerArgs.cpp +++ cfe/trunk/lib/Driver/SanitizerArgs.cpp @@ -288,19 +288,18 @@ // Test for -fno-rtti + explicit -fsanitizer=vptr before expanding groups // so we don't error out if -fno-rtti and -fsanitize=undefined were // passed. - if (Add & Vptr && - (RTTIMode == ToolChain::RM_DisabledImplicitly || - RTTIMode == ToolChain::RM_DisabledExplicitly)) { - if (RTTIMode == ToolChain::RM_DisabledImplicitly) - // Warn about not having rtti enabled if the vptr sanitizer is - // explicitly enabled - D.Diag(diag::warn_drv_disabling_vptr_no_rtti_default); - else { - const llvm::opt::Arg *NoRTTIArg = TC.getRTTIArg(); - assert(NoRTTIArg && - "RTTI disabled explicitly but we have no argument!"); + if ((Add & Vptr) && (RTTIMode == ToolChain::RM_Disabled)) { + if (const llvm::opt::Arg *NoRTTIArg = TC.getRTTIArg()) { + assert(NoRTTIArg->getOption().matches(options::OPT_fno_rtti) && + "RTTI disabled without -fno-rtti option?"); + // The user explicitly passed -fno-rtti with -fsanitize=vptr, but + // the vptr sanitizer requires RTTI, so this is a user error. D.Diag(diag::err_drv_argument_not_allowed_with) << "-fsanitize=vptr" << NoRTTIArg->getAsString(Args); + } else { + // The vptr sanitizer requires RTTI, but RTTI is disabled (by + // default). Warn that the vptr sanitizer is being disabled. + D.Diag(diag::warn_drv_disabling_vptr_no_rtti_default); } // Take out the Vptr sanitizer from the enabled sanitizers @@ -372,9 +371,7 @@ // We disable the vptr sanitizer if it was enabled by group expansion but RTTI // is disabled. - if ((Kinds & Vptr) && - (RTTIMode == ToolChain::RM_DisabledImplicitly || - RTTIMode == ToolChain::RM_DisabledExplicitly)) { + if ((Kinds & Vptr) && (RTTIMode == ToolChain::RM_Disabled)) { Kinds &= ~Vptr; } Index: cfe/trunk/lib/Driver/ToolChain.cpp =================================================================== --- cfe/trunk/lib/Driver/ToolChain.cpp +++ cfe/trunk/lib/Driver/ToolChain.cpp @@ -61,26 +61,13 @@ // Explicit rtti/no-rtti args if (CachedRTTIArg) { if (CachedRTTIArg->getOption().matches(options::OPT_frtti)) - return ToolChain::RM_EnabledExplicitly; + return ToolChain::RM_Enabled; else - return ToolChain::RM_DisabledExplicitly; + return ToolChain::RM_Disabled; } // -frtti is default, except for the PS4 CPU. - if (!Triple.isPS4CPU()) - return ToolChain::RM_EnabledImplicitly; - - // On the PS4, turning on c++ exceptions turns on rtti. - // We're assuming that, if we see -fexceptions, rtti gets turned on. - Arg *Exceptions = Args.getLastArgNoClaim( - options::OPT_fcxx_exceptions, options::OPT_fno_cxx_exceptions, - options::OPT_fexceptions, options::OPT_fno_exceptions); - if (Exceptions && - (Exceptions->getOption().matches(options::OPT_fexceptions) || - Exceptions->getOption().matches(options::OPT_fcxx_exceptions))) - return ToolChain::RM_EnabledImplicitly; - - return ToolChain::RM_DisabledImplicitly; + return (Triple.isPS4CPU()) ? ToolChain::RM_Disabled : ToolChain::RM_Enabled; } ToolChain::ToolChain(const Driver &D, const llvm::Triple &T, Index: cfe/trunk/lib/Driver/ToolChains/Clang.cpp =================================================================== --- cfe/trunk/lib/Driver/ToolChains/Clang.cpp +++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp @@ -412,7 +412,6 @@ const ToolChain &TC, bool KernelOrKext, const ObjCRuntime &objcRuntime, ArgStringList &CmdArgs) { - const Driver &D = TC.getDriver(); const llvm::Triple &Triple = TC.getTriple(); if (KernelOrKext) { @@ -454,21 +453,6 @@ ExceptionArg->getOption().matches(options::OPT_fexceptions); if (CXXExceptionsEnabled) { - if (Triple.isPS4CPU()) { - ToolChain::RTTIMode RTTIMode = TC.getRTTIMode(); - assert(ExceptionArg && - "On the PS4 exceptions should only be enabled if passing " - "an argument"); - if (RTTIMode == ToolChain::RM_DisabledExplicitly) { - const Arg *RTTIArg = TC.getRTTIArg(); - assert(RTTIArg && "RTTI disabled explicitly but no RTTIArg!"); - D.Diag(diag::err_drv_argument_not_allowed_with) - << RTTIArg->getAsString(Args) << ExceptionArg->getAsString(Args); - } else if (RTTIMode == ToolChain::RM_EnabledImplicitly) - D.Diag(diag::warn_drv_enabling_rtti_with_exceptions); - } else - assert(TC.getRTTIMode() != ToolChain::RM_DisabledImplicitly); - CmdArgs.push_back("-fcxx-exceptions"); EH = true; @@ -4191,8 +4175,7 @@ ToolChain::RTTIMode RTTIMode = getToolChain().getRTTIMode(); if (KernelOrKext || (types::isCXX(InputType) && - (RTTIMode == ToolChain::RM_DisabledExplicitly || - RTTIMode == ToolChain::RM_DisabledImplicitly))) + (RTTIMode == ToolChain::RM_Disabled))) CmdArgs.push_back("-fno-rtti"); // -fshort-enums=0 is default for all architectures except Hexagon. Index: cfe/trunk/test/Driver/rtti-options.cpp =================================================================== --- cfe/trunk/test/Driver/rtti-options.cpp +++ cfe/trunk/test/Driver/rtti-options.cpp @@ -1,11 +1,11 @@ // Check that we emit warnings/errors for different combinations of -// exceptions, rtti, and vptr sanitizer flags when targeting the PS4. +// exceptions, rtti, and vptr sanitizer flags for generic (unknown) x86 linux, +// and for PS4 when its behaviour differs from the generic x86-linux. // No warnings/errors should be emitted for unknown, except if combining // the vptr sanitizer with -fno-rtti // Special cases: -fcxx-exceptions in C code should warn about unused arguments // We should also not have any rtti-related arguments -// RUN: %clang -x c -### -target x86_64-scei-ps4 -c -fcxx-exceptions %s 2>&1 | FileCheck -check-prefix=CHECK-UNUSED -check-prefix=CHECK-RTTI %s // RUN: %clang -x c -### -target x86_64-unknown-unknown -c -fcxx-exceptions %s 2>&1 | FileCheck -check-prefix=CHECK-UNUSED -check-prefix=CHECK-RTTI %s // Make sure we keep the last -frtti/-fno-rtti argument @@ -22,28 +22,18 @@ // RUN: %clang -### -c -target x86_64-unknown-linux -fsanitize=undefined %s 2>&1 | FileCheck -check-prefix=CHECK-OK %s // RUN: %clang -### -c -target x86_64-unknown-linux -fsanitize=undefined -frtti %s 2>&1 | FileCheck -check-prefix=CHECK-OK %s // RUN: %clang -### -c -target x86_64-scei-ps4 -fsanitize=vptr %s 2>&1 | FileCheck -check-prefix=CHECK-SAN-WARN %s -// RUN: %clang -### -c -target x86_64-scei-ps4 -fsanitize=vptr -frtti %s 2>&1 | FileCheck -check-prefix=CHECK-OK %s -// RUN: %clang -### -c -target x86_64-scei-ps4 -fsanitize=vptr -fno-rtti %s 2>&1 | FileCheck -check-prefix=CHECK-SAN-ERROR %s -// RUN: %clang -### -c -target x86_64-scei-ps4 -fsanitize=undefined -frtti %s 2>&1 | FileCheck -check-prefix=CHECK-OK %s // Exceptions + no/default rtti -// RUN: %clang -### -c -target x86_64-scei-ps4 -fcxx-exceptions -fno-rtti %s 2>&1 | FileCheck -check-prefix=CHECK-EXC-ERROR-CXX %s -// RUN: %clang -### -c -target x86_64-scei-ps4 -fcxx-exceptions %s 2>&1 | FileCheck -check-prefix=CHECK-EXC-WARN %s // RUN: %clang -### -c -target x86_64-unknown-unknown -fcxx-exceptions -fno-rtti %s 2>&1 | FileCheck -check-prefix=CHECK-OK %s // RUN: %clang -### -c -target x86_64-unknown-unknown -fcxx-exceptions %s 2>&1 | FileCheck -check-prefix=CHECK-OK %s // In C++, -fexceptions implies -fcxx-exceptions -// RUN: %clang -x c++ -### -c -target x86_64-scei-ps4 -fexceptions -fno-rtti %s 2>&1 | FileCheck -check-prefix=CHECK-EXC-ERROR %s -// RUN: %clang -x c++ -### -c -target x86_64-scei-ps4 -fexceptions %s 2>&1 | FileCheck -check-prefix=CHECK-EXC-WARN %s // RUN: %clang -x c++ -### -c -target x86_64-unknown-unknown -fexceptions -fno-rtti %s 2>&1 | FileCheck -check-prefix=CHECK-OK %s // RUN: %clang -x c++ -### -c -target x86_64-unknown-unknown -fexceptions %s 2>&1 | FileCheck -check-prefix=CHECK-OK %s // -frtti + exceptions -// RUN: %clang -### -c -target x86_64-scei-ps4 -fcxx-exceptions -frtti %s 2>&1 | FileCheck -check-prefix=CHECK-OK %s // RUN: %clang -### -c -target x86_64-unknown-unknown -fcxx-exceptions -frtti %s 2>&1 | FileCheck -check-prefix=CHECK-OK %s // -f{no-,}rtti/default -// RUN: %clang -### -c -target x86_64-scei-ps4 -frtti %s 2>&1 | FileCheck -check-prefix=CHECK-RTTI %s -// RUN: %clang -### -c -target x86_64-scei-ps4 -fno-rtti %s 2>&1 | FileCheck -check-prefix=CHECK-NO-RTTI %s // RUN: %clang -### -c -target x86_64-scei-ps4 %s 2>&1 | FileCheck -check-prefix=CHECK-NO-RTTI %s // RUN: %clang -### -c -target x86_64-unknown-unknown -frtti %s 2>&1 | FileCheck -check-prefix=CHECK-RTTI %s // RUN: %clang -### -c -target x86_64-unknown-unknown -fno-rtti %s 2>&1 | FileCheck -check-prefix=CHECK-NO-RTTI %s @@ -52,9 +42,6 @@ // CHECK-UNUSED: warning: argument unused during compilation: '-fcxx-exceptions' // CHECK-SAN-WARN: implicitly disabling vptr sanitizer because rtti wasn't enabled // CHECK-SAN-ERROR: invalid argument '-fsanitize=vptr' not allowed with '-fno-rtti' -// CHECK-EXC-WARN: implicitly enabling rtti for exception handling -// CHECK-EXC-ERROR: invalid argument '-fno-rtti' not allowed with '-fexceptions' -// CHECK-EXC-ERROR-CXX: invalid argument '-fno-rtti' not allowed with '-fcxx-exceptions' // CHECK-RTTI-NOT: "-fno-rtti" // CHECK-NO-RTTI: "-fno-rtti"