Commit 96e5f661bd

Andrew Kelley <andrew@ziglang.org>
2021-11-22 01:07:18
zig cc: add -fcolor-diagnostics and -fcaret-diagnostics integration
Closes #6290
1 parent ceeb230
src/clang_options_data.zig
@@ -2569,12 +2569,26 @@ flagpd1("fcall-saved-x18"),
 flagpd1("fcall-saved-x8"),
 flagpd1("fcall-saved-x9"),
 flagpd1("fcaller-saves"),
-flagpd1("fcaret-diagnostics"),
+.{
+    .name = "fcaret-diagnostics",
+    .syntax = .flag,
+    .zig_equivalent = .color_diagnostics,
+    .pd1 = true,
+    .pd2 = false,
+    .psl = false,
+},
 sepd1("fcaret-diagnostics-max-lines"),
 flagpd1("fcf-protection"),
 flagpd1("fchar8_t"),
 flagpd1("fcheck-array-temporaries"),
-flagpd1("fcolor-diagnostics"),
+.{
+    .name = "fcolor-diagnostics",
+    .syntax = .flag,
+    .zig_equivalent = .color_diagnostics,
+    .pd1 = true,
+    .pd2 = false,
+    .psl = false,
+},
 flagpd1("fcommon"),
 flagpd1("fcompatibility-qualified-id-block-type-checking"),
 flagpd1("fcomplete-member-pointers"),
@@ -2937,10 +2951,24 @@ flagpd1("fno-bounds-check"),
 flagpd1("fno-branch-count-reg"),
 flagpd1("fno-builtin"),
 flagpd1("fno-caller-saves"),
-flagpd1("fno-caret-diagnostics"),
+.{
+    .name = "fno-caret-diagnostics",
+    .syntax = .flag,
+    .zig_equivalent = .no_color_diagnostics,
+    .pd1 = true,
+    .pd2 = false,
+    .psl = false,
+},
 flagpd1("fno-char8_t"),
 flagpd1("fno-check-array-temporaries"),
-flagpd1("fno-color-diagnostics"),
+.{
+    .name = "fno-color-diagnostics",
+    .syntax = .flag,
+    .zig_equivalent = .no_color_diagnostics,
+    .pd1 = true,
+    .pd2 = false,
+    .psl = false,
+},
 flagpd1("fno-common"),
 flagpd1("fno-complete-member-pointers"),
 flagpd1("fno-concept-satisfaction-caching"),
src/main.zig
@@ -1292,6 +1292,8 @@ fn buildOutputType(
                     .no_omit_frame_pointer => omit_frame_pointer = false,
                     .function_sections => function_sections = true,
                     .no_function_sections => function_sections = false,
+                    .color_diagnostics => color = .on,
+                    .no_color_diagnostics => color = .off,
                     .unwind_tables => want_unwind_tables = true,
                     .no_unwind_tables => want_unwind_tables = false,
                     .nostdlib => ensure_libc_on_non_freestanding = false,
@@ -3820,11 +3822,13 @@ pub const ClangArgIterator = struct {
         no_red_zone,
         omit_frame_pointer,
         no_omit_frame_pointer,
+        function_sections,
+        no_function_sections,
+        color_diagnostics,
+        no_color_diagnostics,
         strip,
         exec_model,
         emit_llvm,
-        function_sections,
-        no_function_sections,
     };
 
     const Args = struct {
tools/update_clang_options.zig
@@ -316,6 +316,22 @@ const known_options = [_]KnownOpt{
         .name = "fno-function-sections",
         .ident = "no_function_sections",
     },
+    .{
+        .name = "fcolor-diagnostics",
+        .ident = "color_diagnostics",
+    },
+    .{
+        .name = "fno-color-diagnostics",
+        .ident = "no_color_diagnostics",
+    },
+    .{
+        .name = "fcaret-diagnostics",
+        .ident = "color_diagnostics",
+    },
+    .{
+        .name = "fno-caret-diagnostics",
+        .ident = "no_color_diagnostics",
+    },
     .{
         .name = "MD",
         .ident = "dep_file",