mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2025-01-03 06:10:23 +00:00
[Driver] Don't pass -fmessage-length=0 to CC1
-fmessage-length=0 is common (unless the environment variable COLUMNS is set and exported. This simplifies a common CC1 command line.
This commit is contained in:
parent
855e738be2
commit
4805901930
@ -453,8 +453,6 @@ def fspell_checking_limit : Separate<["-"], "fspell-checking-limit">, MetaVarNam
|
||||
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">;
|
||||
def fmessage_length : Separate<["-"], "fmessage-length">, MetaVarName<"<N>">,
|
||||
HelpText<"Format message diagnostics so that they fit within N columns or fewer, when possible.">;
|
||||
def verify_EQ : CommaJoined<["-"], "verify=">,
|
||||
MetaVarName<"<prefixes>">,
|
||||
HelpText<"Verify diagnostic output using comment directives that start with"
|
||||
|
@ -1364,7 +1364,8 @@ def fmacro_backtrace_limit_EQ : Joined<["-"], "fmacro-backtrace-limit=">,
|
||||
Group<f_Group>, Flags<[DriverOption, CoreOption]>;
|
||||
def fmerge_all_constants : Flag<["-"], "fmerge-all-constants">, Group<f_Group>,
|
||||
Flags<[CC1Option, CoreOption]>, HelpText<"Allow merging of constants">;
|
||||
def fmessage_length_EQ : Joined<["-"], "fmessage-length=">, Group<f_Group>;
|
||||
def fmessage_length_EQ : Joined<["-"], "fmessage-length=">, Group<f_Group>, Flags<[CC1Option]>,
|
||||
HelpText<"Format message diagnostics so that they fit within N columns">;
|
||||
def fms_extensions : Flag<["-"], "fms-extensions">, Group<f_Group>, Flags<[CC1Option, CoreOption]>,
|
||||
HelpText<"Accept some non-standard constructs supported by the Microsoft compiler">;
|
||||
def fms_compatibility : Flag<["-"], "fms-compatibility">, Group<f_Group>, Flags<[CC1Option, CoreOption]>,
|
||||
|
@ -5130,15 +5130,20 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
|
||||
}
|
||||
|
||||
// Pass -fmessage-length=.
|
||||
CmdArgs.push_back("-fmessage-length");
|
||||
unsigned MessageLength = 0;
|
||||
if (Arg *A = Args.getLastArg(options::OPT_fmessage_length_EQ)) {
|
||||
CmdArgs.push_back(A->getValue());
|
||||
StringRef V(A->getValue());
|
||||
if (V.getAsInteger(0, MessageLength))
|
||||
D.Diag(diag::err_drv_invalid_argument_to_option)
|
||||
<< V << A->getOption().getName();
|
||||
} else {
|
||||
// If -fmessage-length=N was not specified, determine whether this is a
|
||||
// terminal and, if so, implicitly define -fmessage-length appropriately.
|
||||
unsigned N = llvm::sys::Process::StandardErrColumns();
|
||||
CmdArgs.push_back(Args.MakeArgString(Twine(N)));
|
||||
MessageLength = llvm::sys::Process::StandardErrColumns();
|
||||
}
|
||||
if (MessageLength != 0)
|
||||
CmdArgs.push_back(
|
||||
Args.MakeArgString("-fmessage-length=" + Twine(MessageLength)));
|
||||
|
||||
// -fvisibility= and -fvisibility-ms-compat are of a piece.
|
||||
if (const Arg *A = Args.getLastArg(options::OPT_fvisibility_EQ,
|
||||
|
@ -1675,7 +1675,8 @@ bool clang::ParseDiagnosticArgs(DiagnosticOptions &Opts, ArgList &Args,
|
||||
Diags->Report(diag::warn_ignoring_ftabstop_value)
|
||||
<< Opts.TabStop << DiagnosticOptions::DefaultTabStop;
|
||||
}
|
||||
Opts.MessageLength = getLastArgIntValue(Args, OPT_fmessage_length, 0, Diags);
|
||||
Opts.MessageLength =
|
||||
getLastArgIntValue(Args, OPT_fmessage_length_EQ, 0, Diags);
|
||||
addDiagnosticArgs(Args, OPT_W_Group, OPT_W_value_Group, Opts.Warnings);
|
||||
addDiagnosticArgs(Args, OPT_R_Group, OPT_R_value_Group, Opts.Remarks);
|
||||
|
||||
|
9
clang/test/Driver/fmessage-length.c
Normal file
9
clang/test/Driver/fmessage-length.c
Normal file
@ -0,0 +1,9 @@
|
||||
// RUN: %clang -### -c %s -fmessage-length=80 2>&1 | FileCheck %s
|
||||
// CHECK: "-fmessage-length=80"
|
||||
|
||||
/// Omit -fmessage-length=0 to simplify common CC1 command lines.
|
||||
// RUN: %clang -### -c %s -fmessage-length=0 2>&1 | FileCheck --check-prefix=ZERO %s
|
||||
// ZERO-NOT: "-fmessage-length=0"
|
||||
|
||||
// RUN: %clang -### -c %s -fmessage-length=nan 2>&1 | FileCheck --check-prefix=ERR %s
|
||||
// ERR: error: invalid argument 'nan' to -fmessage-length=
|
@ -3,11 +3,11 @@
|
||||
// TEST0: clang{{.*}}" "-cc1"
|
||||
// TEST0: "-rewrite-objc"
|
||||
// FIXME: CHECK-NOT is broken somehow, it doesn't work here. Check adjacency instead.
|
||||
// TEST0: "-fmessage-length" "0" "-stack-protector" "1" "-fblocks" "-fencode-extended-block-signature" "-fregister-global-dtors-with-atexit" "-fgnuc-version=4.2.1" "-fobjc-runtime=macosx-fragile" "-fno-objc-infer-related-result-type" "-fobjc-exceptions" "-fexceptions" "-fmax-type-align=16" "-fdiagnostics-show-option"
|
||||
// TEST0: "-stack-protector" "1" "-fblocks" "-fencode-extended-block-signature" "-fregister-global-dtors-with-atexit" "-fgnuc-version=4.2.1" "-fobjc-runtime=macosx-fragile" "-fno-objc-infer-related-result-type" "-fobjc-exceptions" "-fexceptions" "-fmax-type-align=16" "-fdiagnostics-show-option"
|
||||
// TEST0: rewrite-legacy-objc.m"
|
||||
// RUN: %clang -no-canonical-prefixes -target i386-apple-macosx10.9.0 -rewrite-legacy-objc %s -o - -### 2>&1 | \
|
||||
// RUN: FileCheck -check-prefix=TEST1 %s
|
||||
// RUN: %clang -no-canonical-prefixes -target i386-apple-macosx10.6.0 -rewrite-legacy-objc %s -o - -### 2>&1 | \
|
||||
// RUN: FileCheck -check-prefix=TEST2 %s
|
||||
// TEST1: "-fmessage-length" "0" "-stack-protector" "1" "-fblocks" "-fencode-extended-block-signature" "-fregister-global-dtors-with-atexit" "-fgnuc-version=4.2.1" "-fobjc-runtime=macosx-fragile" "-fobjc-subscripting-legacy-runtime" "-fno-objc-infer-related-result-type" "-fobjc-exceptions" "-fmax-type-align=16" "-fdiagnostics-show-option"
|
||||
// TEST2: "-fmessage-length" "0" "-stack-protector" "1" "-fblocks" "-fencode-extended-block-signature" "-fregister-global-dtors-with-atexit" "-fgnuc-version=4.2.1" "-fobjc-runtime=macosx-fragile" "-fobjc-subscripting-legacy-runtime" "-fno-objc-infer-related-result-type" "-fobjc-exceptions" "-fmax-type-align=16" "-fdiagnostics-show-option"
|
||||
// TEST1: "-stack-protector" "1" "-fblocks" "-fencode-extended-block-signature" "-fregister-global-dtors-with-atexit" "-fgnuc-version=4.2.1" "-fobjc-runtime=macosx-fragile" "-fobjc-subscripting-legacy-runtime" "-fno-objc-infer-related-result-type" "-fobjc-exceptions" "-fmax-type-align=16" "-fdiagnostics-show-option"
|
||||
// TEST2: "-stack-protector" "1" "-fblocks" "-fencode-extended-block-signature" "-fregister-global-dtors-with-atexit" "-fgnuc-version=4.2.1" "-fobjc-runtime=macosx-fragile" "-fobjc-subscripting-legacy-runtime" "-fno-objc-infer-related-result-type" "-fobjc-exceptions" "-fmax-type-align=16" "-fdiagnostics-show-option"
|
||||
|
@ -3,4 +3,4 @@
|
||||
// TEST0: clang{{.*}}" "-cc1"
|
||||
// TEST0: "-rewrite-objc"
|
||||
// FIXME: CHECK-NOT is broken somehow, it doesn't work here. Check adjacency instead.
|
||||
// TEST0: "-fmessage-length" "0" "-stack-protector" "1" "-fblocks" "-fencode-extended-block-signature" "-fregister-global-dtors-with-atexit" "-fgnuc-version=4.2.1" "-fobjc-runtime=macosx" "-fno-objc-infer-related-result-type" "-fobjc-exceptions" "-fexceptions" "-fmax-type-align=16" "-fdiagnostics-show-option"
|
||||
// TEST0: "-stack-protector" "1" "-fblocks" "-fencode-extended-block-signature" "-fregister-global-dtors-with-atexit" "-fgnuc-version=4.2.1" "-fobjc-runtime=macosx" "-fno-objc-infer-related-result-type" "-fobjc-exceptions" "-fexceptions" "-fmax-type-align=16" "-fdiagnostics-show-option"
|
||||
|
@ -1,4 +1,4 @@
|
||||
// RUN: not %clang_cc1 -fsyntax-only -fmessage-length 75 -o /dev/null -x c < %s 2>&1 | FileCheck %s -strict-whitespace
|
||||
// RUN: not %clang_cc1 -fsyntax-only -fmessage-length=75 -o /dev/null -x c < %s 2>&1 | FileCheck %s -strict-whitespace
|
||||
// REQUIRES: utf8-capable-terminal
|
||||
|
||||
// Test case for the text diagnostics source column conversion crash.
|
||||
|
@ -1,5 +1,5 @@
|
||||
// RUN: not %clang_cc1 -fsyntax-only -fmessage-length 60 %s 2>&1 | FileCheck %s
|
||||
// RUN: not %clang_cc1 -fsyntax-only -fmessage-length 0 %s 2>&1 | FileCheck %s
|
||||
// RUN: not %clang_cc1 -fsyntax-only -fmessage-length=60 %s 2>&1 | FileCheck %s
|
||||
// RUN: not %clang_cc1 -fsyntax-only -fmessage-length=0 %s 2>&1 | FileCheck %s
|
||||
|
||||
struct B { void f(); };
|
||||
struct D1 : B {};
|
||||
|
@ -1,6 +1,6 @@
|
||||
// RUN: not %clang_cc1 -fmessage-length 72 %s 2>&1 | FileCheck -strict-whitespace %s
|
||||
// RUN: not %clang_cc1 -fmessage-length 1 %s
|
||||
// RUN: not %clang_cc1 -fmessage-length 8 %s 2>&1 | FileCheck -check-prefix=CHECK-DOT %s
|
||||
// RUN: not %clang_cc1 -fmessage-length=72 %s 2>&1 | FileCheck -strict-whitespace %s
|
||||
// RUN: not %clang_cc1 -fmessage-length=1 %s
|
||||
// RUN: not %clang_cc1 -fmessage-length=8 %s 2>&1 | FileCheck -check-prefix=CHECK-DOT %s
|
||||
// Hack so we can check things better, force the file name and line.
|
||||
# 1 "FILE" 1
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
// RUN: %clang_cc1 -fsyntax-only -fmessage-length 80 %s 2>&1 | FileCheck -strict-whitespace %s
|
||||
// RUN: %clang_cc1 -fsyntax-only -fmessage-length=80 %s 2>&1 | FileCheck -strict-whitespace %s
|
||||
|
||||
int main() {
|
||||
"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
|
||||
@ -12,4 +12,4 @@ int main() {
|
||||
|
||||
"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" ;
|
||||
// CHECK: {{^ ..."xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"...}}
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
// RUN: not %clang_cc1 %s -fmessage-length 40 2>&1 | FileCheck -strict-whitespace %s
|
||||
// RUN: not %clang_cc1 %s -fmessage-length=40 2>&1 | FileCheck -strict-whitespace %s
|
||||
|
||||
int main() {
|
||||
int i;
|
||||
|
@ -1,4 +1,4 @@
|
||||
// RUN: %clang_cc1 -fsyntax-only -fmessage-length 100 %s 2>&1 | FileCheck -strict-whitespace %s
|
||||
// RUN: %clang_cc1 -fsyntax-only -fmessage-length=100 %s 2>&1 | FileCheck -strict-whitespace %s
|
||||
// REQUIRES: asserts
|
||||
|
||||
int main() {
|
||||
|
Loading…
Reference in New Issue
Block a user