[clang][Driver] Add -fcaret-diagnostics-max-lines= as a driver option

Since https://reviews.llvm.org/D147875 landed, setting different values
(or reverting to the old default of 1) is more important than before,
so promote this option to a driver flag.

Differential Revision: https://reviews.llvm.org/D152090
This commit is contained in:
Timm Bäder 2023-06-04 07:49:36 +02:00
parent 8a19af513d
commit 5cc721b3f9
7 changed files with 15 additions and 8 deletions

View File

@ -230,9 +230,11 @@ New Compiler Flags
------------------
- The flag ``-std=c++23`` has been added. This behaves the same as the existing
flag ``-std=c++2b``.
- ``-dumpdir`` has been implemented to specify auxiliary and dump output
filenames for features like ``-gsplit-dwarf``.
- ``-fcaret-diagnostics-max-lines=`` has been added as a driver options, which
lets users control the maximum number of source lines printed for a
caret diagnostic.
Deprecated Compiler Flags
-------------------------

View File

@ -2312,6 +2312,11 @@ def fmacro_backtrace_limit_EQ : Joined<["-"], "fmacro-backtrace-limit=">,
Group<f_Group>, Flags<[NoXarchOption, CC1Option, CoreOption]>,
HelpText<"Set the maximum number of entries to print in a macro expansion backtrace (0 = no limit)">,
MarshallingInfoInt<DiagnosticOpts<"MacroBacktraceLimit">, "DiagnosticOptions::DefaultMacroBacktraceLimit">;
def fcaret_diagnostics_max_lines_EQ :
Joined<["-"], "fcaret-diagnostics-max-lines=">,
Group<f_Group>, Flags<[CC1Option, CoreOption]>,
HelpText<"Set the maximum number of source lines to show in a caret diagnostic (0 = no limit).">,
MarshallingInfoInt<DiagnosticOpts<"SnippetLineLimit">, "DiagnosticOptions::DefaultSnippetLineLimit">;
defm merge_all_constants : BoolFOption<"merge-all-constants",
CodeGenOpts<"MergeAllConstants">, DefaultFalse,
PosFlag<SetTrue, [CC1Option, CoreOption], "Allow">, NegFlag<SetFalse, [], "Disallow">,
@ -6003,10 +6008,6 @@ def ftabstop : Separate<["-"], "ftabstop">, MetaVarName<"<N>">,
def ferror_limit : Separate<["-"], "ferror-limit">, MetaVarName<"<N>">,
HelpText<"Set the maximum number of errors to emit before stopping (0 = no limit).">,
MarshallingInfoInt<DiagnosticOpts<"ErrorLimit">>;
def fcaret_diagnostics_max_lines :
Separate<["-"], "fcaret-diagnostics-max-lines">, MetaVarName<"<N>">,
HelpText<"Set the maximum number of source lines to show in a caret diagnostic">,
MarshallingInfoInt<DiagnosticOpts<"SnippetLineLimit">, "DiagnosticOptions::DefaultSnippetLineLimit">;
def verify_EQ : CommaJoined<["-"], "verify=">,
MetaVarName<"<prefixes>">,
HelpText<"Verify diagnostic output using comment directives that start with"

View File

@ -6062,6 +6062,7 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
Args.AddLastArg(CmdArgs, options::OPT_fmacro_backtrace_limit_EQ);
Args.AddLastArg(CmdArgs, options::OPT_ftemplate_backtrace_limit_EQ);
Args.AddLastArg(CmdArgs, options::OPT_fspell_checking_limit_EQ);
Args.AddLastArg(CmdArgs, options::OPT_fcaret_diagnostics_max_lines_EQ);
// Pass -fmessage-length=.
unsigned MessageLength = 0;

View File

@ -0,0 +1,3 @@
//RUN: %clang++ -### -fcaret-diagnostics-max-lines=2 %s 2>&1 | FileCheck %s
// CHECK: "-fcaret-diagnostics-max-lines=2"

View File

@ -1,4 +1,4 @@
// RUN: not %clang_cc1 -fdiagnostics-parseable-fixits -fno-diagnostics-show-line-numbers -fcaret-diagnostics-max-lines 1 -x c++ %s 2> %t
// RUN: not %clang_cc1 -fdiagnostics-parseable-fixits -fno-diagnostics-show-line-numbers -fcaret-diagnostics-max-lines=1 -x c++ %s 2> %t
// RUN: FileCheck %s < %t
// PR5941
// END.

View File

@ -1,4 +1,4 @@
// RUN: not %clang_cc1 -std=c++11 -fno-diagnostics-show-line-numbers -fcaret-diagnostics-max-lines 5 -Wsometimes-uninitialized %s 2>&1 | FileCheck %s --strict-whitespace
// RUN: not %clang_cc1 -std=c++11 -fno-diagnostics-show-line-numbers -fcaret-diagnostics-max-lines=5 -Wsometimes-uninitialized %s 2>&1 | FileCheck %s --strict-whitespace
void line(int);

View File

@ -1,4 +1,4 @@
// RUN: not %clang_cc1 -std=c++11 -fsyntax-only -fno-diagnostics-show-line-numbers -fcaret-diagnostics-max-lines 5 %s 2>&1 | FileCheck %s -strict-whitespace
// RUN: not %clang_cc1 -std=c++11 -fsyntax-only -fno-diagnostics-show-line-numbers -fcaret-diagnostics-max-lines=5 %s 2>&1 | FileCheck %s -strict-whitespace
//CHECK: {{.*}}: error: excess elements in scalar initializer