Skip to content

Commit 994457f

Browse files
authored
[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
1 parent e650ac1 commit 994457f

File tree

5 files changed

+13
-5
lines changed

5 files changed

+13
-5
lines changed

clang/docs/ReleaseNotes.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -445,6 +445,9 @@ New Compiler Flags
445445
- The ``-Warray-compare-cxx26`` warning has been added to warn about array comparison
446446
starting from C++26, this warning is enabled as an error by default.
447447

448+
- clang-cl and clang-dxc now support ``-fdiagnostics-color=[auto|never|always]``
449+
in addition to ``-f[no-]color-diagnostics``.
450+
448451
Deprecated Compiler Flags
449452
-------------------------
450453

clang/include/clang/Driver/Options.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1990,7 +1990,7 @@ def : Flag<["-"], "fno-diagnostics-color">, Group<f_Group>,
19901990
Visibility<[ClangOption, CLOption, DXCOption, FlangOption]>,
19911991
Alias<fno_color_diagnostics>;
19921992
def fdiagnostics_color_EQ : Joined<["-"], "fdiagnostics-color=">, Group<f_Group>,
1993-
Visibility<[ClangOption, FlangOption]>,
1993+
Visibility<[ClangOption, CLOption, DXCOption, FlangOption]>,
19941994
Values<"auto,always,never">,
19951995
HelpText<"When to use colors in diagnostics">;
19961996
def fansi_escape_codes : Flag<["-"], "fansi-escape-codes">, Group<f_Group>,

clang/test/Driver/cl-options.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -680,6 +680,7 @@
680680
// RUN: -fcoverage-mapping \
681681
// RUN: -fno-coverage-mapping \
682682
// RUN: -fdiagnostics-color \
683+
// RUN: -fdiagnostics-color=auto \
683684
// RUN: -fno-diagnostics-color \
684685
// RUN: -fdebug-compilation-dir . \
685686
// RUN: -fdebug-compilation-dir=. \

clang/test/Driver/dxc_options.hlsl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// RUN: %clang_dxc \
2+
// RUN: -fcolor-diagnostics \
3+
// RUN: -fno-color-diagnostics \
4+
// RUN: -fdiagnostics-color \
5+
// RUN: -fno-diagnostics-color \
6+
// RUN: -fdiagnostics-color=auto \
7+
// RUN: -Tlib_6_7 -Vd -fdriver-only -- %s 2>&1 |count 0
8+

clang/test/Driver/unknown-arg-drivermodes.test

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// RUN: %clang_cl \
22
// RUN: --config \
3-
// RUN: -fdiagnostics-color=auto \
43
// RUN: -fno-record-command-line \
54
// RUN: -frecord-command-line \
65
// RUN: -nodefaultlibs \
@@ -15,7 +14,6 @@
1514

1615
// RUN: not %clang_dxc \
1716
// RUN: --config \
18-
// RUN: -fdiagnostics-color=auto \
1917
// RUN: -fno-record-command-line \
2018
// RUN: -frecord-command-line \
2119
// RUN: -nodefaultlibs \
@@ -30,7 +28,6 @@
3028
// RUN: | FileCheck %s --check-prefix=DXC --implicit-check-not="error:"
3129

3230
// CL: warning: unknown argument ignored in clang-cl: '--config'
33-
// CL: warning: unknown argument ignored in clang-cl: '-fdiagnostics-color=auto'
3431
// CL: warning: unknown argument ignored in clang-cl: '-fno-record-command-line'
3532
// CL: warning: unknown argument ignored in clang-cl: '-frecord-command-line'
3633
// CL: warning: unknown argument ignored in clang-cl: '-nodefaultlibs'
@@ -42,7 +39,6 @@
4239
// CL: warning: unknown argument ignored in clang-cl: '-Xoffload-linker'
4340

4441
// DXC: error: unknown argument: '--config'
45-
// DXC: error: unknown argument: '-fdiagnostics-color=auto'
4642
// DXC: error: unknown argument: '-fno-record-command-line'
4743
// DXC: error: unknown argument: '-frecord-command-line'
4844
// DXC: error: unknown argument: '-nodefaultlibs'

0 commit comments

Comments
 (0)