Index: include/clang/Driver/Options.td =================================================================== --- include/clang/Driver/Options.td +++ include/clang/Driver/Options.td @@ -808,7 +808,7 @@ Flags<[CC1Option]>, HelpText<"Print option name with mappable diagnostics">; def fdiagnostics_show_note_include_stack : Flag<["-"], "fdiagnostics-show-note-include-stack">, Group, Flags<[CC1Option]>, HelpText<"Display include stacks for diagnostic notes">; -def fdiagnostics_format_EQ : Joined<["-"], "fdiagnostics-format=">, Group; +def fdiagnostics_format_EQ : Joined<["-"], "fdiagnostics-format=">, Group, Flags<[CC1Option, CC1AsOption]>; def fdiagnostics_show_category_EQ : Joined<["-"], "fdiagnostics-show-category=">, Group; def fdiagnostics_show_template_tree : Flag<["-"], "fdiagnostics-show-template-tree">, Group, Flags<[CC1Option]>, @@ -1197,7 +1197,7 @@ def fms_compatibility_version : Joined<["-"], "fms-compatibility-version=">, Group, - Flags<[ CC1Option, CoreOption ]>, + Flags<[ CC1Option, CoreOption, CC1AsOption ]>, HelpText<"Dot-separated value representing the Microsoft compiler " "version number to report in _MSC_VER (0 = don't define it " "(default))">; @@ -1372,7 +1372,7 @@ def fno_rtti_data : Flag<["-"], "fno-rtti-data">, Group, Flags<[CC1Option]>, HelpText<"Control emission of RTTI data">; def fno_short_enums : Flag<["-"], "fno-short-enums">, Group; -def fno_show_column : Flag<["-"], "fno-show-column">, Group, Flags<[CC1Option]>, +def fno_show_column : Flag<["-"], "fno-show-column">, Group, Flags<[CC1Option, CC1AsOption]>, HelpText<"Do not include column number on diagnostics">; def fno_show_source_location : Flag<["-"], "fno-show-source-location">, Group, Flags<[CC1Option]>, HelpText<"Do not include source location information with diagnostics">; Index: lib/Driver/ToolChains/Clang.cpp =================================================================== --- lib/Driver/ToolChains/Clang.cpp +++ lib/Driver/ToolChains/Clang.cpp @@ -2068,6 +2068,20 @@ CmdArgs.push_back("-target-feature"); CmdArgs.push_back(MipsTargetFeature); } + + if (const Arg *A = Args.getLastArg(options::OPT_fdiagnostics_format_EQ)) { + CmdArgs.push_back( + Args.MakeArgString(Twine("-fdiagnostics-format=") + A->getValue())); + } + + if (!Args.hasFlag(options::OPT_fshow_column, options::OPT_fno_show_column, + true)) + CmdArgs.push_back("-fno-show-column"); + + VersionTuple MSVT = C.getDefaultToolChain().computeMSVCVersion(&D, Args); + if (!MSVT.empty()) + CmdArgs.push_back( + Args.MakeArgString("-fms-compatibility-version=" + MSVT.getAsString())); } static void RenderFloatingPointOptions(const ToolChain &TC, const Driver &D, @@ -2839,6 +2853,10 @@ if (const Arg *A = Args.getLastArg(options::OPT_fdiagnostics_format_EQ)) { CmdArgs.push_back("-fdiagnostics-format"); CmdArgs.push_back(A->getValue()); + + CmdArgs.push_back("-backend-option"); + std::string Opt = std::string("-diagnostics-format=") + A->getValue(); + CmdArgs.push_back(Args.MakeArgString(Opt)); } if (const Arg *A = Args.getLastArg( @@ -2887,8 +2905,11 @@ CmdArgs.push_back("-fdiagnostics-absolute-paths"); if (!Args.hasFlag(options::OPT_fshow_column, options::OPT_fno_show_column, - ColumnDefault)) + ColumnDefault)) { CmdArgs.push_back("-fno-show-column"); + CmdArgs.push_back("-backend-option"); + CmdArgs.push_back("-show-column=false"); + } if (!Args.hasFlag(options::OPT_fspell_checking, options::OPT_fno_spell_checking)) @@ -4223,10 +4244,15 @@ CmdArgs.push_back("-fms-compatibility"); VersionTuple MSVT = getToolChain().computeMSVCVersion(&D, Args); - if (!MSVT.empty()) + if (!MSVT.empty()) { CmdArgs.push_back( Args.MakeArgString("-fms-compatibility-version=" + MSVT.getAsString())); + CmdArgs.push_back("-backend-option"); + CmdArgs.push_back( + Args.MakeArgString("-ms-compatibility-version=" + MSVT.getAsString())); + } + bool IsMSVC2015Compatible = MSVT.getMajor() >= 19; if (ImplyVCPPCXXVer) { StringRef LanguageStandard; Index: test/Misc/diag-format-asm.s =================================================================== --- test/Misc/diag-format-asm.s +++ test/Misc/diag-format-asm.s @@ -0,0 +1,52 @@ +// RUN: not %clang %s 2>&1 | FileCheck %s -check-prefix=DEFAULT +// RUN: not %clang -fdiagnostics-format=clang %s 2>&1 | FileCheck %s -check-prefix=DEFAULT +// RUN: not %clang -fdiagnostics-format=clang -target x86_64-pc-win32 %s 2>&1 | FileCheck %s -check-prefix=DEFAULT --strict-whitespace +// +// RUN: not %clang -fdiagnostics-format=msvc -fmsc-version=1300 %s 2>&1 | FileCheck %s -check-prefix=MSVC2010 --strict-whitespace +// RUN: not %clang -fdiagnostics-format=msvc -fms-compatibility-version=13.00 %s 2>&1 | FileCheck %s -check-prefix=MSVC2010 --strict-whitespace +// RUN: not %clang -fdiagnostics-format=msvc -fmsc-version=1300 -target x86_64-pc-win32 %s 2>&1 | FileCheck %s -check-prefix=MSVC2010 --strict-whitespace +// RUN: not %clang -fdiagnostics-format=msvc -fms-compatibility-version=13.00 -target x86_64-pc-win32 %s 2>&1 | FileCheck %s -check-prefix=MSVC2010 --strict-whitespace +// RUN: not %clang -fdiagnostics-format=msvc -fmsc-version=1300 -target x86_64-pc-win32 -fshow-column %s 2>&1 | FileCheck %s -check-prefix=MSVC2010 --strict-whitespace +// RUN: not %clang -fdiagnostics-format=msvc -fmsc-version=1800 -target x86_64-pc-win32 %s 2>&1 | FileCheck %s -check-prefix=MSVC2013 --strict-whitespace +// RUN: not %clang -fdiagnostics-format=msvc -target x86_64-pc-win32 %s 2>&1 | FileCheck %s -check-prefix=MSVC --strict-whitespace +// RUN: not %clang -fdiagnostics-format=msvc -fmsc-version=1900 -target x86_64-pc-win32 %s 2>&1 | FileCheck %s -check-prefix=MSVC2015 --strict-whitespace +// RUN: not %clang -fdiagnostics-format=msvc -fms-compatibility-version=13.00 -target x86_64-pc-win32 -fshow-column %s 2>&1 | FileCheck %s -check-prefix=MSVC2010 --strict-whitespace +// RUN: not %clang -fdiagnostics-format=msvc -fmsc-version=1800 -target x86_64-pc-win32 -fshow-column %s 2>&1 | FileCheck %s -check-prefix=MSVC2013 --strict-whitespace +// RUN: not %clang -fdiagnostics-format=msvc -target x86_64-pc-win32 -fshow-column %s 2>&1 | FileCheck %s -check-prefix=MSVC --strict-whitespace +// RUN: not %clang -fdiagnostics-format=msvc -fmsc-version=1900 -target x86_64-pc-win32 -fshow-column %s 2>&1 | FileCheck %s -check-prefix=MSVC2015 --strict-whitespace +// +// RUN: not %clang -fdiagnostics-format=vi %s 2>&1 | FileCheck %s -check-prefix=VI --strict-whitespace +// +// RUN: not %clang -fdiagnostics-format=msvc -fno-show-column -fmsc-version=1900 %s 2>&1 | FileCheck %s -check-prefix=MSVC2015_ORIG --strict-whitespace +// +// RUN: not %clang -fno-show-column %s 2>&1 | FileCheck %s -check-prefix=NO_COLUMN --strict-whitespace +// +// RUN: not %clang -Werror -fdiagnostics-format=msvc-fallback -fmsc-version=1300 %s 2>&1 | FileCheck %s -check-prefix=MSVC2010-FALLBACK --strict-whitespace +// RUN: not %clang -Werror -fdiagnostics-format=msvc-fallback -fms-compatibility-version=13.00 %s 2>&1 | FileCheck %s -check-prefix=MSVC2010-FALLBACK --strict-whitespace +// RUN: not %clang -Werror -fdiagnostics-format=msvc-fallback -fmsc-version=1800 %s 2>&1 | FileCheck %s -check-prefix=MSVC2013-FALLBACK --strict-whitespace +// RUN: not %clang -Werror -fdiagnostics-format=msvc-fallback -fmsc-version=1900 %s 2>&1 | FileCheck %s -check-prefix=MSVC2015-FALLBACK --strict-whitespace + + +// DEFAULT: {{.*}}:48:5: error: invalid instruction mnemonic 'deliberate_error' +// MSVC2010: {{.*}}(48,4) : error: invalid instruction mnemonic 'deliberate_error' +// MSVC2013: {{.*}}(48,5) : error: invalid instruction mnemonic 'deliberate_error' +// MSVC: {{.*}}(48,5){{ ?}}: error: invalid instruction mnemonic 'deliberate_error' +// MSVC2015: {{.*}}(48,5): error: invalid instruction mnemonic 'deliberate_error' +// VI: {{.*}} +48:5: error: invalid instruction mnemonic 'deliberate_error' +// MSVC2015_ORIG: {{.*}}(48): error: invalid instruction mnemonic 'deliberate_error' +// NO_COLUMN: {{.*}}:48: error: invalid instruction mnemonic 'deliberate_error' +// MSVC2010-FALLBACK: {{.*}}(48,4) : error: invalid instruction mnemonic 'deliberate_error' +// MSVC2013-FALLBACK: {{.*}}(48,5) : error: invalid instruction mnemonic 'deliberate_error' +// MSVC2015-FALLBACK: {{.*}}(48,5): error: invalid instruction mnemonic 'deliberate_error' + +//*********** +.section .text +.global TestFunc_ASM +TestFunc_ASM: + nop + nop + deliberate_error + ret +//*********** + +