r212805 - GCC compatibility: Create a Group to ignore unsupported optimization.

Sylvestre Ledru sylvestre at debian.org
Fri Jul 11 04:43:57 PDT 2014


Author: sylvestre
Date: Fri Jul 11 06:43:57 2014
New Revision: 212805

URL: http://llvm.org/viewvc/llvm-project?rev=212805&view=rev
Log:
GCC compatibility: Create a Group to ignore unsupported optimization.

Returns a warning when using an unknown optimization flag.
This patch includes -finline-limit as one of those ignored flags.
More options will be moved in this group

Patch by Arthur Marble <arthur at info9.net> in the context of
Debian Google Summer of code 2014.

Reviewers: rnk, Sylvestre


Modified:
    cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
    cfe/trunk/include/clang/Driver/Options.td
    cfe/trunk/lib/Driver/Tools.cpp
    cfe/trunk/test/Driver/clang_f_opts.c

Modified: cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td?rev=212805&r1=212804&r2=212805&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td Fri Jul 11 06:43:57 2014
@@ -119,6 +119,8 @@ def err_drv_emit_llvm_link : Error<
 def err_drv_optimization_remark_pattern : Error<
   "%0 in '%1'">;
 
+def warn_ignored_gcc_optimization : Warning<"ignoring unsupported optimization flag '%0'">,
+  InGroup<UnusedCommandLineArgument>;
 def warn_O4_is_O3 : Warning<"-O4 is equivalent to -O3">, InGroup<Deprecated>;
 def warn_drv_optimization_value : Warning<"optimization level '%0' is unsupported; using '%1%2' instead">,
   InGroup<InvalidCommandLineArgument>;

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=212805&r1=212804&r2=212805&view=diff
==============================================================================
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Fri Jul 11 06:43:57 2014
@@ -91,6 +91,10 @@ def clang_ignored_f_Group : OptionGroup<
 def clang_ignored_m_Group : OptionGroup<"<clang ignored m group>">,
   Group<m_Group>;
 
+// Group that ignores all gcc optimizations that won't be implemented
+def clang_ignored_gcc_optimization_f_Group : OptionGroup<
+  "<clang_ignored_gcc_optimization_f_Group>">, Group<f_Group>;
+
 /////////
 // Options
 
@@ -1591,7 +1595,8 @@ defm gcse : BooleanFFlag<"gcse">, Group<
 defm gnu : BooleanFFlag<"gnu">, Group<clang_ignored_f_Group>;
 defm ident : BooleanFFlag<"ident">, Group<clang_ignored_f_Group>;
 defm implicit_templates : BooleanFFlag<"implicit-templates">, Group<clang_ignored_f_Group>;
-defm inline_limit : BooleanFFlag<"inline-limit">, Group<clang_ignored_f_Group>;
+def finline_limit_EQ : Joined<["-"], "finline-limit=">, Group<clang_ignored_gcc_optimization_f_Group>;
+defm finline_limit : BooleanFFlag<"inline-limit">, Group<clang_ignored_gcc_optimization_f_Group>;
 defm ivopts : BooleanFFlag<"ivopts">, Group<clang_ignored_f_Group>;
 defm non_call_exceptions : BooleanFFlag<"non-call-exceptions">, Group<clang_ignored_f_Group>;
 defm permissive : BooleanFFlag<"permissive">, Group<clang_ignored_f_Group>;

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=212805&r1=212804&r2=212805&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Fri Jul 11 06:43:57 2014
@@ -3138,6 +3138,13 @@ void Clang::ConstructJob(Compilation &C,
     }
   }
 
+  // Warn about ignored options to clang.
+  for (arg_iterator it = Args.filtered_begin(
+       options::OPT_clang_ignored_gcc_optimization_f_Group),
+       ie = Args.filtered_end(); it != ie; ++it) {
+    D.Diag(diag::warn_ignored_gcc_optimization) << (*it)->getAsString(Args);
+  }
+
   // Don't warn about unused -flto.  This can happen when we're preprocessing or
   // precompiling.
   Args.ClaimAllArgs(options::OPT_flto);

Modified: cfe/trunk/test/Driver/clang_f_opts.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/clang_f_opts.c?rev=212805&r1=212804&r2=212805&view=diff
==============================================================================
--- cfe/trunk/test/Driver/clang_f_opts.c (original)
+++ cfe/trunk/test/Driver/clang_f_opts.c Fri Jul 11 06:43:57 2014
@@ -164,9 +164,17 @@
 // RUN:     -fno-unsigned-char                                                \
 // RUN:     -fno-signed-char                                                  \
 // RUN:     -fstrength-reduce -fno-strength-reduce                            \
+// RUN:     -finline-limit=1000                                               \
+// RUN:     -finline-limit                                                    \
 // RUN:     %s 2>&1 | FileCheck --check-prefix=IGNORE %s
 // IGNORE-NOT: error: unknown argument
 
+// Test that the warning is displayed on these.
+// RUN: %clang -### -finline-limit=1000 %s 2>&1 | FileCheck --check-prefix=CHECK-WARNING1 %s
+// RUN: %clang -### -finline-limit %s 2>&1 | FileCheck --check-prefix=CHECK-WARNING2 %s
+// CHECK-WARNING1: ignoring unsupported optimization flag '-finline-limit=1000
+// CHECK-WARNING2: ignoring unsupported optimization flag '-finline-limit'
+
 // RUN: %clang -### -fshort-wchar -fno-short-wchar %s 2>&1 | FileCheck -check-prefix=CHECK-WCHAR1 %s
 // RUN: %clang -### -fno-short-wchar -fshort-wchar %s 2>&1 | FileCheck -check-prefix=CHECK-WCHAR2 %s
 // CHECK-WCHAR1: -fno-short-wchar





More information about the cfe-commits mailing list