diff options
| author | Hans Wennborg <hans@hanshq.net> | 2013-07-31 20:51:53 +0000 |
|---|---|---|
| committer | Hans Wennborg <hans@hanshq.net> | 2013-07-31 20:51:53 +0000 |
| commit | 1907610d4e1cd85634d8e7e31001fdf899cc3ad5 (patch) | |
| tree | 9fc0dbe7f746deab16d4cdbac0b4595a13b3a55a | |
| parent | ca69a53bae802896a7c3705c52d81f4819ee62ab (diff) | |
| download | bcm5719-llvm-1907610d4e1cd85634d8e7e31001fdf899cc3ad5.tar.gz bcm5719-llvm-1907610d4e1cd85634d8e7e31001fdf899cc3ad5.zip | |
clang-cl: add the /c, /W0 and /W1 options
This adds a few more clang-cl options. It also exposes two core clang
options to the clang-cl mode: we need to be able to claim --driver_mode
so it doesn't show up as unused in cl mode, and we need -### for tests.
Differential Revision: http://llvm-reviews.chandlerc.com/D1232
llvm-svn: 187527
| -rw-r--r-- | clang/include/clang/Driver/CLCompatOptions.td | 10 | ||||
| -rw-r--r-- | clang/include/clang/Driver/Options.h | 7 | ||||
| -rw-r--r-- | clang/include/clang/Driver/Options.td | 10 | ||||
| -rw-r--r-- | clang/lib/Driver/Driver.cpp | 6 | ||||
| -rw-r--r-- | clang/test/Driver/cl-options.c | 10 |
5 files changed, 32 insertions, 11 deletions
diff --git a/clang/include/clang/Driver/CLCompatOptions.td b/clang/include/clang/Driver/CLCompatOptions.td index 2c1554f6857..aef92915f90 100644 --- a/clang/include/clang/Driver/CLCompatOptions.td +++ b/clang/include/clang/Driver/CLCompatOptions.td @@ -12,10 +12,14 @@ //===----------------------------------------------------------------------===// def cl_Group : OptionGroup<"<clang-cl options>">, - HelpText<"CL.EXE COMPATIBILITY OPTIONS">; + HelpText<"CL.EXE COMPATIBILITY OPTIONS">; class CLFlag<string name> : Option<["/", "-"], name, KIND_FLAG>, - Group<cl_Group>, Flags<[CLOption]>; + Group<cl_Group>, Flags<[CLOption, DriverOption]>; def _QUESTION : CLFlag<"?">, Alias<help>, HelpText<"Display available options">; -def cl_help : CLFlag<"help">, Alias<help>, HelpText<"Display available options">; +def _SLASH_c : CLFlag<"c">, HelpText<"Compile only">, Alias<c>; +def _SLASH_help : CLFlag<"help">, Alias<help>, + HelpText<"Display available options">; +def _SLASH_W0 : CLFlag<"W0">, HelpText<"Disable all warnings">, Alias<w>; +def _SLASH_W1 : CLFlag<"W1">, HelpText<"Enable -Wall">, Alias<Wall>; diff --git a/clang/include/clang/Driver/Options.h b/clang/include/clang/Driver/Options.h index 99ec12579f8..0af8d3fe9e5 100644 --- a/clang/include/clang/Driver/Options.h +++ b/clang/include/clang/Driver/Options.h @@ -27,9 +27,10 @@ enum ClangFlags { LinkerInput = (1 << 5), NoArgumentUnused = (1 << 6), Unsupported = (1 << 7), - CLOption = (1 << 8), - CC1Option = (1 << 9), - NoDriverOption = (1 << 10) + CoreOption = (1 << 8), + CLOption = (1 << 9), + CC1Option = (1 << 10), + NoDriverOption = (1 << 11) }; enum ID { diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index 38ed61708c4..d3b61a51ca0 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -33,6 +33,10 @@ def NoArgumentUnused : OptionFlag; // lines that use it. def Unsupported : OptionFlag; +// CoreOption - This is considered a "core" Clang option, available in both +// clang and clang-cl modes. +def CoreOption : OptionFlag; + // CLOption - This is a cl.exe compatibility option. Options with this flag // are made available when the driver is running in CL compatibility mode. def CLOption : OptionFlag; @@ -98,6 +102,7 @@ def clang_ignored_m_Group : OptionGroup<"<clang ignored m group>">, // substitutions: // _ => __ // - => _ +// / => _SLASH // # => _HASH // ? => _QUESTION // , => _COMMA @@ -116,7 +121,8 @@ def internal_debug_Group : class InternalDriverOpt : Group<internal_driver_Group>, Flags<[DriverOption, HelpHidden]>; -def driver_mode : Joined<["--"], "driver-mode=">, InternalDriverOpt, +def driver_mode : Joined<["--"], "driver-mode=">, Group<internal_driver_Group>, + Flags<[CoreOption, DriverOption, HelpHidden]>, HelpText<"Set the driver mode to either 'gcc', 'g++', 'cpp', or 'cl'">; def ccc_gcc_name : Separate<["-"], "ccc-gcc-name">, InternalDriverOpt, HelpText<"Name for native GCC compiler">, @@ -171,7 +177,7 @@ def ccc_ : Joined<["-"], "ccc-">, Group<internal_Group>, Flags<[Unsupported]>; // Standard Options -def _HASH_HASH_HASH : Flag<["-"], "###">, Flags<[DriverOption]>, +def _HASH_HASH_HASH : Flag<["-"], "###">, Flags<[DriverOption, CoreOption]>, HelpText<"Print the commands to run for this compilation">; // The '--' option is here for the sake of compatibility with gcc, but is // being ignored by the driver. diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp index 34594e643d6..4f9cd3e38a0 100644 --- a/clang/lib/Driver/Driver.cpp +++ b/clang/lib/Driver/Driver.cpp @@ -1883,9 +1883,9 @@ std::pair<unsigned, unsigned> Driver::getIncludeExcludeOptionFlagMasks() const { unsigned ExcludedFlagsBitmask = 0; if (Mode == CLMode) { - // Only allow CL options. - // FIXME: Also allow "core" Clang options. - IncludedFlagsBitmask = options::CLOption; + // Include CL and Core options. + IncludedFlagsBitmask |= options::CLOption; + IncludedFlagsBitmask |= options::CoreOption; } else { ExcludedFlagsBitmask |= options::CLOption; } diff --git a/clang/test/Driver/cl-options.c b/clang/test/Driver/cl-options.c new file mode 100644 index 00000000000..ece48c553da --- /dev/null +++ b/clang/test/Driver/cl-options.c @@ -0,0 +1,10 @@ +// Don't attempt slash switches on msys bash. +// REQUIRES: shell-preserves-root + +// RUN: %clang_cl /c /W0 %s -### 2>&1 | FileCheck -check-prefix=W0 %s +// W0-DAG: -c +// W0-DAG: -w + +// RUN: %clang_cl /c /W1 %s -### 2>&1 | FileCheck -check-prefix=W1 %s +// W1-DAG: -c +// W1-DAG: -Wall |

