[clang] 994457f - [Clang-CL][DXC] Expose -fdiagnostic-color= to clang-cl and clang-dxc (#120644)
via cfe-commits
cfe-commits at lists.llvm.org
Fri Dec 20 14:12:29 PST 2024
Author: Chris White
Date: 2024-12-20T23:12:25+01:00
New Revision: 994457f81ffd95531eff07e08a0fea42397b80d2
URL: https://github.com/llvm/llvm-project/commit/994457f81ffd95531eff07e08a0fea42397b80d2
DIFF: https://github.com/llvm/llvm-project/commit/994457f81ffd95531eff07e08a0fea42397b80d2.diff
LOG: [Clang-CL][DXC] Expose -fdiagnostic-color= to clang-cl and clang-dxc (#120644)
Exposing `-fdiagnostic-color=` to clang-cl and clang-dxc.
`-fcolor-diagnostics` and `-fno-color-diagnostics` are already allowed
in both of these and `-fdiagnostics-color=` allows one additional value,
`auto`.
I've added the tests for clang-cl to `cl-options.c` as per the comments
in the issue linked below. I couldn't finding a suitable existing file
to add the clang-dxc tests to so I've created a new one.
Resolves #119184
Added:
clang/test/Driver/dxc_options.hlsl
Modified:
clang/docs/ReleaseNotes.rst
clang/include/clang/Driver/Options.td
clang/test/Driver/cl-options.c
clang/test/Driver/unknown-arg-drivermodes.test
Removed:
################################################################################
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index d9d016b30f93d6..3560efaebd2a0f 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -445,6 +445,9 @@ New Compiler Flags
- The ``-Warray-compare-cxx26`` warning has been added to warn about array comparison
starting from C++26, this warning is enabled as an error by default.
+- clang-cl and clang-dxc now support ``-fdiagnostics-color=[auto|never|always]``
+ in addition to ``-f[no-]color-diagnostics``.
+
Deprecated Compiler Flags
-------------------------
diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td
index 9edf308cc685ea..9e81c39f6869bd 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -1990,7 +1990,7 @@ def : Flag<["-"], "fno-diagnostics-color">, Group<f_Group>,
Visibility<[ClangOption, CLOption, DXCOption, FlangOption]>,
Alias<fno_color_diagnostics>;
def fdiagnostics_color_EQ : Joined<["-"], "fdiagnostics-color=">, Group<f_Group>,
- Visibility<[ClangOption, FlangOption]>,
+ Visibility<[ClangOption, CLOption, DXCOption, FlangOption]>,
Values<"auto,always,never">,
HelpText<"When to use colors in diagnostics">;
def fansi_escape_codes : Flag<["-"], "fansi-escape-codes">, Group<f_Group>,
diff --git a/clang/test/Driver/cl-options.c b/clang/test/Driver/cl-options.c
index 477e8489e74280..c975727839c0bf 100644
--- a/clang/test/Driver/cl-options.c
+++ b/clang/test/Driver/cl-options.c
@@ -680,6 +680,7 @@
// RUN: -fcoverage-mapping \
// RUN: -fno-coverage-mapping \
// RUN: -fdiagnostics-color \
+// RUN: -fdiagnostics-color=auto \
// RUN: -fno-diagnostics-color \
// RUN: -fdebug-compilation-dir . \
// RUN: -fdebug-compilation-dir=. \
diff --git a/clang/test/Driver/dxc_options.hlsl b/clang/test/Driver/dxc_options.hlsl
new file mode 100644
index 00000000000000..09fdba1c3dd5f4
--- /dev/null
+++ b/clang/test/Driver/dxc_options.hlsl
@@ -0,0 +1,8 @@
+// RUN: %clang_dxc \
+// RUN: -fcolor-diagnostics \
+// RUN: -fno-color-diagnostics \
+// RUN: -fdiagnostics-color \
+// RUN: -fno-diagnostics-color \
+// RUN: -fdiagnostics-color=auto \
+// RUN: -Tlib_6_7 -Vd -fdriver-only -- %s 2>&1 |count 0
+
diff --git a/clang/test/Driver/unknown-arg-drivermodes.test b/clang/test/Driver/unknown-arg-drivermodes.test
index a7ea73af345e03..0125d79b47afa1 100644
--- a/clang/test/Driver/unknown-arg-drivermodes.test
+++ b/clang/test/Driver/unknown-arg-drivermodes.test
@@ -1,6 +1,5 @@
// RUN: %clang_cl \
// RUN: --config \
-// RUN: -fdiagnostics-color=auto \
// RUN: -fno-record-command-line \
// RUN: -frecord-command-line \
// RUN: -nodefaultlibs \
@@ -15,7 +14,6 @@
// RUN: not %clang_dxc \
// RUN: --config \
-// RUN: -fdiagnostics-color=auto \
// RUN: -fno-record-command-line \
// RUN: -frecord-command-line \
// RUN: -nodefaultlibs \
@@ -30,7 +28,6 @@
// RUN: | FileCheck %s --check-prefix=DXC --implicit-check-not="error:"
// CL: warning: unknown argument ignored in clang-cl: '--config'
-// CL: warning: unknown argument ignored in clang-cl: '-fdiagnostics-color=auto'
// CL: warning: unknown argument ignored in clang-cl: '-fno-record-command-line'
// CL: warning: unknown argument ignored in clang-cl: '-frecord-command-line'
// CL: warning: unknown argument ignored in clang-cl: '-nodefaultlibs'
@@ -42,7 +39,6 @@
// CL: warning: unknown argument ignored in clang-cl: '-Xoffload-linker'
// DXC: error: unknown argument: '--config'
-// DXC: error: unknown argument: '-fdiagnostics-color=auto'
// DXC: error: unknown argument: '-fno-record-command-line'
// DXC: error: unknown argument: '-frecord-command-line'
// DXC: error: unknown argument: '-nodefaultlibs'
More information about the cfe-commits
mailing list