r232860 - Don't claim exception related arguments when looking at RTTIMode

Filipe Cabecinhas me at filcab.net
Fri Mar 20 16:33:23 PDT 2015

Author: filcab
Date: Fri Mar 20 18:33:23 2015
New Revision: 232860

URL: http://llvm.org/viewvc/llvm-project?rev=232860&view=rev
Don't claim exception related arguments when looking at RTTIMode

We were claiming the -f*exceptions arguments when looking for the
RTTIMode. This makes us not warn about unused arguments if compiling a C
file with -fcxx-exceptions.

This patch fixes it by not claiming the exception-related arguments at
that point.

Reviewers: rsmith, samsonov

Subscribers: cfe-commits

Differential Revision: http://reviews.llvm.org/D8507


Modified: cfe/trunk/lib/Driver/ToolChain.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChain.cpp?rev=232860&r1=232859&r2=232860&view=diff
--- cfe/trunk/lib/Driver/ToolChain.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChain.cpp Fri Mar 20 18:33:23 2015
@@ -48,7 +48,7 @@ static ToolChain::RTTIMode CalculateRTTI
   // 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.getLastArg(
+  Arg *Exceptions = Args.getLastArgNoClaim(
       options::OPT_fcxx_exceptions, options::OPT_fno_cxx_exceptions,
       options::OPT_fexceptions, options::OPT_fno_exceptions);
   if (Exceptions &&

Modified: cfe/trunk/test/Driver/rtti-options.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/rtti-options.cpp?rev=232860&r1=232859&r2=232860&view=diff
--- cfe/trunk/test/Driver/rtti-options.cpp (original)
+++ cfe/trunk/test/Driver/rtti-options.cpp Fri Mar 20 18:33:23 2015
@@ -3,6 +3,10 @@
 // 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'
 // 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

More information about the cfe-commits mailing list