[PATCH] D29101: Ignore -f(no)objc-arc-exception when -fno-objc-arc set

Onha Choe via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Jan 24 15:38:09 PST 2017


onhachoe created this revision.

Sometime clang would be supplied -fobjc-arc -f(no)objc-arc-exceptions
and then later disable ARC with -fno-objc-arc, which only negate first
option, but not the latter, resulting usused argument warning.
Silence this warning only when -fno-objc-arc option is present.


https://reviews.llvm.org/D29101

Files:
  lib/Driver/Tools.cpp
  test/Driver/no-arc-exception-silence.m


Index: test/Driver/no-arc-exception-silence.m
===================================================================
--- /dev/null
+++ test/Driver/no-arc-exception-silence.m
@@ -0,0 +1,2 @@
+// RUN: %clang -Werror -fobjc-arc -fobjc-arc-exceptions -fno-objc-arc -Xclang -verify -c %s
+// expected-no-diagnostics
Index: lib/Driver/Tools.cpp
===================================================================
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -6018,7 +6018,13 @@
                      options::OPT_fno_objc_arc_exceptions,
                      /*default*/ types::isCXX(InputType)))
       CmdArgs.push_back("-fobjc-arc-exceptions");
+  }
 
+  // Silence warning for full exception code emission options when explicitly
+  // set to use no ARC.
+  if (Args.hasArg(options::OPT_fno_objc_arc)) {
+    Args.ClaimAllArgs(options::OPT_fobjc_arc_exceptions);
+    Args.ClaimAllArgs(options::OPT_fno_objc_arc_exceptions);
   }
 
   // -fobjc-infer-related-result-type is the default, except in the Objective-C


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D29101.85647.patch
Type: text/x-patch
Size: 1017 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170124/8b211048/attachment.bin>


More information about the cfe-commits mailing list