]> granicus.if.org Git - clang/commitdiff
Mark -Xclang as being a compilation-only option so that the clang driver
authorRichard Smith <richard-llvm@metafoo.co.uk>
Mon, 18 Apr 2016 23:12:59 +0000 (23:12 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Mon, 18 Apr 2016 23:12:59 +0000 (23:12 +0000)
doesn't warn if it's passed to a link action. This matches the behavior for
most other compilation-only options (including things like -f flags), and is
necessary to suppress warnings on systems like cmake that always pass all
compile flags to the linker.

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

include/clang/Driver/Options.td
test/Driver/linker-opts.c

index 1a8c7c606d199a0d65d05e05ef9394ceea95f766..a28518e8c665a70025c597482bb75a51b36b16ab 100644 (file)
@@ -337,7 +337,7 @@ def Xassembler : Separate<["-"], "Xassembler">,
   HelpText<"Pass <arg> to the assembler">, MetaVarName<"<arg>">;
 def Xclang : Separate<["-"], "Xclang">,
   HelpText<"Pass <arg> to the clang compiler">, MetaVarName<"<arg>">,
-  Flags<[DriverOption, CoreOption]>;
+  Flags<[DriverOption, CoreOption]>, Group<CompileOnly_Group>;
 def Xcuda_fatbinary : Separate<["-"], "Xcuda-fatbinary">,
   HelpText<"Pass <arg> to fatbinary invocation">, MetaVarName<"<arg>">;
 def Xcuda_ptxas : Separate<["-"], "Xcuda-ptxas">,
index 24866a63b1fd9a333889c467e239c01e7d975c9e..29ef136c8b71f1a62f58c2fa439657d5b1cd06d3 100644 (file)
@@ -1,3 +1,6 @@
+// RUN: rm -rf %t
+// RUN: mkdir %t
+//
 // RUN: env LIBRARY_PATH=%T/test1 %clang -x c %s -### 2>&1 | FileCheck %s
 // CHECK: "-L{{.*}}/test1"
 
@@ -9,3 +12,12 @@
 // Make sure that LIBRARY_PATH works for both i386 and x86_64 on Darwin.
 // RUN: env LIBRARY_PATH=%T/test1 %clang -target x86_64-apple-darwin %s -### 2>&1 | FileCheck %s
 // RUN: env LIBRARY_PATH=%T/test1 %clang -target i386-apple-darwin  %s -### 2>&1 | FileCheck %s
+//
+// Make sure that we don't warn on unused compiler arguments.
+// RUN: %clang -Xclang -I. -x c %s -c -o %t/tmp.o
+// RUN: %clang -Xclang -I. %t/tmp.o -o %t/tmp -### 2>&1 | FileCheck %s --check-prefix=NO-UNUSED
+// NO-UNUSED-NOT: warning:{{.*}}unused
+//
+// Make sure that we do warn in other cases.
+// RUN: %clang %s -lfoo -c -o %t/tmp2.o -### 2>&1 | FileCheck %s --check-prefix=UNUSED
+// UNUSED: warning:{{.*}}unused