[PATCH] D11766: "Claim" the arguments belonging to 'clang_ignored_gcc_optimization_f_Group'
Douglas Katzman
dougk at google.com
Wed Aug 5 10:16:07 PDT 2015
dougk created this revision.
dougk added reviewers: chandlerc, rnk.
dougk added a subscriber: cfe-commits.
This seems preferable to printing two warnings per use of an unsupported option- one about not supporting it, and one about the compiler invocation not using it.
It also makes the '-Wno-' flag do what you mean with respect to those ignored options. Given that clang_ignored_f_Group are silently ignored, it seems obvious that the W flag is intended to suppress warnings about things that would otherwise print something, not arguments that are totally effectless.
Though why there are two groups at all is strange - the gcc group was added in r212805 when the clang_ignored_f_group already existed. I suppose it would have been incompatible to make the clang_ignored_f_group start to issue warnings.
http://reviews.llvm.org/D11766
Files:
lib/Driver/Tools.cpp
test/Driver/clang_f_opts.c
Index: test/Driver/clang_f_opts.c
===================================================================
--- test/Driver/clang_f_opts.c
+++ test/Driver/clang_f_opts.c
@@ -412,6 +412,19 @@
// CHECK-NO-WARNING1-NOT: optimization flag '-finline-limit=1000' is not supported
// CHECK-NO-WARNING2-NOT: optimization flag '-finline-limit' is not supported
+// Test that an ignored optimization argument only prints 1 warning,
+// not both a warning about not claiming the arg, *and* about ignoring the arg,
+// and that adding -Wno-ignored-optimization silences the warning.
+//
+// RUN: %clang -### -fprofile-correction %s 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-NO-WARNING3 %s
+// CHECK-NO-WARNING3: optimization flag '-fprofile-correction' is not supported
+// CHECK-NO-WARNING3-NOT: argument unused
+// RUN: %clang -### -fprofile-correction -Wno-ignored-optimization-argument %s 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-NO-WARNING4 %s
+// CHECK-NO-WARNING4-NOT: not supported
+// CHECK-NO-WARNING4-NOT: argument unused
+
// RUN: %clang -### -S -fsigned-char %s 2>&1 | FileCheck -check-prefix=CHAR-SIGN1 %s
// CHAR-SIGN1-NOT: -fno-signed-char
Index: lib/Driver/Tools.cpp
===================================================================
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -3848,6 +3848,7 @@
for (const Arg *A :
Args.filtered(options::OPT_clang_ignored_gcc_optimization_f_Group)) {
D.Diag(diag::warn_ignored_gcc_optimization) << A->getAsString(Args);
+ A->claim();
}
claimNoWarnArgs(Args);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D11766.31364.patch
Type: text/x-patch
Size: 1560 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20150805/2199ed4d/attachment.bin>
More information about the cfe-commits
mailing list