From ee6ad7af45a0be36191e0d55f005d9a0dd8005be Mon Sep 17 00:00:00 2001 From: Stephen Long Date: Mon, 13 Jun 2022 11:20:26 -0700 Subject: [PATCH] [clang-cl][MSVC] Map /external:Wn n=1-4 to -Wsystem-headers https://docs.microsoft.com/en-us/cpp/build/reference/external-external-headers-diagnostics?view=msvc-170 Reviewed By: hans Differential Revision: https://reviews.llvm.org/D127452 --- clang/include/clang/Driver/Options.td | 7 +++++++ clang/test/Driver/cl-options.c | 8 ++++++++ 2 files changed, 15 insertions(+) diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index a5a46bf..563ad46 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -775,6 +775,8 @@ def Wa_COMMA : CommaJoined<["-"], "Wa,">, MetaVarName<"">; def Wall : Flag<["-"], "Wall">, Group, Flags<[CC1Option, HelpHidden]>; def WCL4 : Flag<["-"], "WCL4">, Group, Flags<[CC1Option, HelpHidden]>; +def Wsystem_headers : Flag<["-"], "Wsystem-headers">, Group, Flags<[CC1Option, HelpHidden]>; +def Wno_system_headers : Flag<["-"], "Wno-system-headers">, Group, Flags<[CC1Option, HelpHidden]>; def Wdeprecated : Flag<["-"], "Wdeprecated">, Group, Flags<[CC1Option]>, HelpText<"Enable warnings for deprecated constructs and define __DEPRECATED">; def Wno_deprecated : Flag<["-"], "Wno-deprecated">, Group, Flags<[CC1Option]>; @@ -6475,6 +6477,11 @@ def _SLASH_validate_charset : CLFlag<"validate-charset">, Alias, AliasArgs<["invalid-source-encoding"]>; def _SLASH_validate_charset_ : CLFlag<"validate-charset-">, Alias, AliasArgs<["no-invalid-source-encoding"]>; +def _SLASH_external_W0 : CLFlag<"external:W0">, HelpText<"Ignore warnings from system headers (default)">, Alias; +def _SLASH_external_W1 : CLFlag<"external:W1">, HelpText<"Enable -Wsystem-headers">, Alias; +def _SLASH_external_W2 : CLFlag<"external:W2">, HelpText<"Enable -Wsystem-headers">, Alias; +def _SLASH_external_W3 : CLFlag<"external:W3">, HelpText<"Enable -Wsystem-headers">, Alias; +def _SLASH_external_W4 : CLFlag<"external:W4">, HelpText<"Enable -Wsystem-headers">, Alias; def _SLASH_W0 : CLFlag<"W0">, HelpText<"Disable all warnings">, Alias; def _SLASH_W1 : CLFlag<"W1">, HelpText<"Enable -Wall">, Alias; def _SLASH_W2 : CLFlag<"W2">, HelpText<"Enable -Wall">, Alias; diff --git a/clang/test/Driver/cl-options.c b/clang/test/Driver/cl-options.c index 1e518e0..89a5a90 100644 --- a/clang/test/Driver/cl-options.c +++ b/clang/test/Driver/cl-options.c @@ -752,4 +752,12 @@ // RUN: %clang_cl /JMC /Z7 /c -### -- %s 2>&1 | FileCheck %s --check-prefix JMC // JMC: -fjmc +// RUN: %clang_cl /external:W0 /c -### -- %s 2>&1 | FileCheck -check-prefix=EXTERNAL_W0 %s +// RUN: %clang_cl /external:W1 /c -### -- %s 2>&1 | FileCheck -check-prefix=EXTERNAL_Wn %s +// RUN: %clang_cl /external:W2 /c -### -- %s 2>&1 | FileCheck -check-prefix=EXTERNAL_Wn %s +// RUN: %clang_cl /external:W3 /c -### -- %s 2>&1 | FileCheck -check-prefix=EXTERNAL_Wn %s +// RUN: %clang_cl /external:W4 /c -### -- %s 2>&1 | FileCheck -check-prefix=EXTERNAL_Wn %s +// EXTERNAL_W0: "-Wno-system-headers" +// EXTERNAL_Wn: "-Wsystem-headers" + void f(void) { } -- 2.7.4