]> granicus.if.org Git - clang/commitdiff
Driver: ignore -fno-objc-arc-exception when -fno-objc-arc set
authorSaleem Abdulrasool <compnerd@compnerd.org>
Wed, 25 Jan 2017 03:36:28 +0000 (03:36 +0000)
committerSaleem Abdulrasool <compnerd@compnerd.org>
Wed, 25 Jan 2017 03:36:28 +0000 (03:36 +0000)
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.

Patch by Onha Choe!

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@293014 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Driver/Tools.cpp
test/Driver/no-arc-exception-silence.m [new file with mode: 0644]

index c78123b236de547d0d218d19a9480382d0d1b17c..854b5d5cccbcccf2c19caee3c851839302cce3fb 100644 (file)
@@ -6018,7 +6018,13 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
                      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
diff --git a/test/Driver/no-arc-exception-silence.m b/test/Driver/no-arc-exception-silence.m
new file mode 100644 (file)
index 0000000..96b700d
--- /dev/null
@@ -0,0 +1,2 @@
+// RUN: %clang -Werror -fobjc-arc -fobjc-arc-exceptions -fno-objc-arc -Xclang -verify -c %s
+// expected-no-diagnostics