[flang-commits] [flang] 30b1c1f - [Driver] Simplify -f[no-]diagnostics-color handling. NFC
Fangrui Song via flang-commits
flang-commits at lists.llvm.org
Sun Apr 10 01:07:49 PDT 2022
Author: Fangrui Song
Date: 2022-04-10T01:07:44-07:00
New Revision: 30b1c1f23d4d58c3220eac6aee35fd23f109b35c
URL: https://github.com/llvm/llvm-project/commit/30b1c1f23d4d58c3220eac6aee35fd23f109b35c
DIFF: https://github.com/llvm/llvm-project/commit/30b1c1f23d4d58c3220eac6aee35fd23f109b35c.diff
LOG: [Driver] Simplify -f[no-]diagnostics-color handling. NFC
Make them aliases for -f[no-]color-diagnostics.
Added:
Modified:
clang/include/clang/Driver/Options.td
clang/lib/Driver/ToolChains/Clang.cpp
clang/lib/Frontend/CompilerInvocation.cpp
flang/lib/Frontend/CompilerInvocation.cpp
Removed:
################################################################################
diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td
index 98443b2757c93..81d47b2517d02 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -1342,8 +1342,8 @@ def fclang_abi_compat_EQ : Joined<["-"], "fclang-abi-compat=">, Group<f_clang_Gr
def fclasspath_EQ : Joined<["-"], "fclasspath=">, Group<f_Group>;
defm color_diagnostics : OptInCC1FFlag<"color-diagnostics", "Enable", "Disable", " colors in diagnostics",
[CoreOption, FlangOption]>;
-def fdiagnostics_color : Flag<["-"], "fdiagnostics-color">, Group<f_Group>,
- Flags<[CoreOption, NoXarchOption]>;
+def : Flag<["-"], "fdiagnostics-color">, Group<f_Group>, Flags<[CoreOption]>, Alias<fcolor_diagnostics>;
+def : Flag<["-"], "fno-diagnostics-color">, Group<f_Group>, Flags<[CoreOption]>, Alias<fno_color_diagnostics>;
def fdiagnostics_color_EQ : Joined<["-"], "fdiagnostics-color=">, Group<f_Group>;
def fansi_escape_codes : Flag<["-"], "fansi-escape-codes">, Group<f_Group>,
Flags<[CoreOption, CC1Option]>, HelpText<"Use ANSI escape codes for diagnostics">,
@@ -2308,8 +2308,6 @@ def fno_builtin : Flag<["-"], "fno-builtin">, Group<f_Group>, Flags<[CC1Option,
HelpText<"Disable implicit builtin knowledge of functions">;
def fno_builtin_ : Joined<["-"], "fno-builtin-">, Group<f_Group>, Flags<[CC1Option, CoreOption]>,
HelpText<"Disable implicit builtin knowledge of a specific function">;
-def fno_diagnostics_color : Flag<["-"], "fno-diagnostics-color">, Group<f_Group>,
- Flags<[CoreOption, NoXarchOption]>;
def fno_common : Flag<["-"], "fno-common">, Group<f_Group>, Flags<[CC1Option]>,
HelpText<"Compile common globals like normal definitions">;
defm digraphs : BoolFOption<"digraphs",
diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp
index 1cb73f89e081d..0da0c75d0cc5d 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -3957,9 +3957,7 @@ static void RenderDiagnosticsOptions(const Driver &D, const ArgList &Args,
for (const Arg *A : Args) {
const Option &O = A->getOption();
if (!O.matches(options::OPT_fcolor_diagnostics) &&
- !O.matches(options::OPT_fdiagnostics_color) &&
!O.matches(options::OPT_fno_color_diagnostics) &&
- !O.matches(options::OPT_fno_diagnostics_color) &&
!O.matches(options::OPT_fdiagnostics_color_EQ))
continue;
diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp
index bbc6df546941e..6aa85586df069 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -2123,11 +2123,9 @@ static bool parseShowColorsArgs(const ArgList &Args, bool DefaultColor) {
} ShowColors = DefaultColor ? Colors_Auto : Colors_Off;
for (auto *A : Args) {
const Option &O = A->getOption();
- if (O.matches(options::OPT_fcolor_diagnostics) ||
- O.matches(options::OPT_fdiagnostics_color)) {
+ if (O.matches(options::OPT_fcolor_diagnostics)) {
ShowColors = Colors_On;
- } else if (O.matches(options::OPT_fno_color_diagnostics) ||
- O.matches(options::OPT_fno_diagnostics_color)) {
+ } else if (O.matches(options::OPT_fno_color_diagnostics)) {
ShowColors = Colors_Off;
} else if (O.matches(options::OPT_fdiagnostics_color_EQ)) {
StringRef Value(A->getValue());
diff --git a/flang/lib/Frontend/CompilerInvocation.cpp b/flang/lib/Frontend/CompilerInvocation.cpp
index cb94daccd157e..d1f427a15005f 100644
--- a/flang/lib/Frontend/CompilerInvocation.cpp
+++ b/flang/lib/Frontend/CompilerInvocation.cpp
@@ -61,11 +61,9 @@ static bool parseShowColorsArgs(
for (auto *a : args) {
const llvm::opt::Option &O = a->getOption();
- if (O.matches(clang::driver::options::OPT_fcolor_diagnostics) ||
- O.matches(clang::driver::options::OPT_fdiagnostics_color)) {
+ if (O.matches(clang::driver::options::OPT_fcolor_diagnostics)) {
ShowColors = Colors_On;
- } else if (O.matches(clang::driver::options::OPT_fno_color_diagnostics) ||
- O.matches(clang::driver::options::OPT_fno_diagnostics_color)) {
+ } else if (O.matches(clang::driver::options::OPT_fno_color_diagnostics)) {
ShowColors = Colors_Off;
} else if (O.matches(clang::driver::options::OPT_fdiagnostics_color_EQ)) {
llvm::StringRef value(a->getValue());
More information about the flang-commits
mailing list