r232869 - Only add -fno-rtti if KernelOrKext or in C++ mode.
Filipe Cabecinhas
me at filcab.net
Fri Mar 20 16:51:16 PDT 2015
Author: filcab
Date: Fri Mar 20 18:51:15 2015
New Revision: 232869
URL: http://llvm.org/viewvc/llvm-project?rev=232869&view=rev
Log:
Only add -fno-rtti if KernelOrKext or in C++ mode.
Modified:
cfe/trunk/lib/Driver/Tools.cpp
cfe/trunk/test/Driver/rtti-options.cpp
Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=232869&r1=232868&r2=232869&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Fri Mar 20 18:51:15 2015
@@ -4050,8 +4050,9 @@ void Clang::ConstructJob(Compilation &C,
ToolChain::RTTIMode RTTIMode = getToolChain().getRTTIMode();
- if (RTTIMode == ToolChain::RM_DisabledExplicitly ||
- RTTIMode == ToolChain::RM_DisabledImplicitly)
+ if (KernelOrKext || (types::isCXX(InputType) &&
+ (RTTIMode == ToolChain::RM_DisabledExplicitly ||
+ RTTIMode == ToolChain::RM_DisabledImplicitly)))
CmdArgs.push_back("-fno-rtti");
// -fshort-enums=0 is default for all architectures except Hexagon.
Modified: cfe/trunk/test/Driver/rtti-options.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/rtti-options.cpp?rev=232869&r1=232868&r2=232869&view=diff
==============================================================================
--- cfe/trunk/test/Driver/rtti-options.cpp (original)
+++ cfe/trunk/test/Driver/rtti-options.cpp Fri Mar 20 18:51:15 2015
@@ -3,10 +3,12 @@
// No warnings/errors should be emitted for unknown, except if combining
// the vptr sanitizer with -fno-rtti
-// Special case: -fcxx-exceptions in C code should warn about unused arguments
-// RUN: %clang -x c -### -c -fcxx-exceptions %s 2>&1 | FileCheck -check-prefix=CHECK-UNUSED %s
-// CHECK-UNUSED: warning: argument unused during compilation: '-fcxx-exceptions'
+// 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 -check-prefix=CHECK-NO-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 -check-prefix=CHECK-NO-RTTI %s
+// Make sure we keep the last -frtti/-fno-rtti argument
// RUN: %clang -### -c -fno-rtti -frtti %s 2>&1 | FileCheck -check-prefix=CHECK-RTTI %s
// RUN: %clang -### -c -frtti -fno-rtti %s 2>&1 | FileCheck -check-prefix=CHECK-NO-RTTI %s
@@ -48,6 +50,7 @@
// RUN: %clang -### -c -target x86_64-unknown-unknown -fno-rtti %s 2>&1 | FileCheck -check-prefix=CHECK-NO-RTTI %s
// RUN: %clang -### -c -target x86_64-unknown-unknown %s 2>&1 | FileCheck -check-prefix=CHECK-RTTI %s
+// 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
More information about the cfe-commits
mailing list