[Clang] remove text extension from diag::err_drv_invalid_value_with_suggestion

This hinders translations, as per:
https://clang.llvm.org/docs/InternalsManual.html#the-format-string

Reviewed By: MaskRay, xbolva00

Differential Revision: https://reviews.llvm.org/D101387
This commit is contained in:
Nick Desaulniers 2021-05-05 11:01:33 -07:00
parent 8048005739
commit aefbfbcbd7
5 changed files with 16 additions and 15 deletions

View File

@ -216,7 +216,8 @@ def warn_drv_yc_multiple_inputs_clang_cl : Warning<
def err_drv_invalid_value : Error<"invalid value '%1' in '%0'">;
def err_drv_invalid_int_value : Error<"invalid integral value '%1' in '%0'">;
def err_drv_invalid_value_with_suggestion : Error<"invalid value '%1' in '%0','%2'">;
def err_drv_invalid_value_with_suggestion : Error<
"invalid value '%1' in '%0', expected one of: %2">;
def err_drv_invalid_remap_file : Error<
"invalid option '%0' not of the form <from-file>;<to-file>">;
def err_drv_invalid_gcc_output_type : Error<
@ -275,6 +276,10 @@ def err_drv_unsupported_embed_bitcode
: Error<"%0 is not supported with -fembed-bitcode">;
def err_drv_bitcode_unsupported_on_toolchain : Error<
"-fembed-bitcode is not supported on versions of iOS prior to 6.0">;
def err_drv_negative_columns : Error<
"invalid value '%1' in '%0', value must be 'none' or a positive integer">;
def err_drv_small_columns : Error<
"invalid value '%1' in '%0', value must be '%2' or greater">;
def err_drv_invalid_malign_branch_EQ : Error<
"invalid argument '%0' to -malign-branch=; each element must be one of: %1">;

View File

@ -3112,8 +3112,7 @@ static void RenderSSPOptions(const Driver &D, const ToolChain &TC,
<< A->getAsString(Args) << TripleStr;
if (Value != "tls" && Value != "global") {
D.Diag(diag::err_drv_invalid_value_with_suggestion)
<< A->getOption().getName() << Value
<< "valid arguments to '-mstack-protector-guard=' are:tls global";
<< A->getOption().getName() << Value << "tls global";
return;
}
A->render(Args, CmdArgs);
@ -3139,8 +3138,7 @@ static void RenderSSPOptions(const Driver &D, const ToolChain &TC,
<< A->getAsString(Args) << TripleStr;
if (EffectiveTriple.isX86() && (Value != "fs" && Value != "gs")) {
D.Diag(diag::err_drv_invalid_value_with_suggestion)
<< A->getOption().getName() << Value
<< "for X86, valid arguments to '-mstack-protector-guard-reg=' are:fs gs";
<< A->getOption().getName() << Value << "fs gs";
return;
}
A->render(Args, CmdArgs);

View File

@ -7,7 +7,7 @@
// CHECK-TLS: "-cc1" {{.*}}"-mstack-protector-guard=tls"
// CHECK-GLOBAL: "-cc1" {{.*}}"-mstack-protector-guard=global"
// INVALID-VALUE: error: invalid value 'local' in 'mstack-protector-guard=','valid arguments to '-mstack-protector-guard=' are:tls global'
// INVALID-VALUE: error: invalid value 'local' in 'mstack-protector-guard=', expected one of: tls global
// RUN: %clang -### -target x86_64-unknown-unknown -mstack-protector-guard-reg=fs %s 2>&1 | \
// RUN: FileCheck -check-prefix=CHECK-FS %s
@ -35,7 +35,7 @@
// CHECK-FS: "-cc1" {{.*}}"-mstack-protector-guard-reg=fs"
// CHECK-GS: "-cc1" {{.*}}"-mstack-protector-guard-reg=gs"
// INVALID-REG: error: invalid value {{.*}} in 'mstack-protector-guard-reg=','for X86, valid arguments to '-mstack-protector-guard-reg=' are:fs gs'
// INVALID-REG: error: invalid value {{.*}} in 'mstack-protector-guard-reg=', expected one of: fs gs
// RUN: %clang -### -target x86_64-unknown-unknown -mstack-protector-guard-offset=30 %s 2>&1 | \
// RUN: FileCheck -check-prefix=CHECK-OFFSET %s

View File

@ -259,15 +259,13 @@ static bool ParseFrontendArgs(FrontendOptions &opts, llvm::opt::ArgList &args,
columns = -1;
}
if (columns < 0) {
diags.Report(clang::diag::err_drv_invalid_value_with_suggestion)
<< arg->getOption().getName() << arg->getValue()
<< "value must be 'none' or a non-negative integer";
diags.Report(clang::diag::err_drv_negative_columns)
<< arg->getOption().getName() << arg->getValue();
} else if (columns == 0) {
opts.fixedFormColumns_ = 1000000;
} else if (columns < 7) {
diags.Report(clang::diag::err_drv_invalid_value_with_suggestion)
<< arg->getOption().getName() << arg->getValue()
<< "value must be at least seven";
diags.Report(clang::diag::err_drv_small_columns)
<< arg->getOption().getName() << arg->getValue() << "7";
} else {
opts.fixedFormColumns_ = columns;
}

View File

@ -37,12 +37,12 @@
!-----------------------------------------
! EXPECTED OUTPUT WITH A NEGATIVE LENGTH
!-----------------------------------------
! NEGATIVELENGTH: invalid value '-2' in 'ffixed-line-length=','value must be 'none' or a non-negative integer'
! NEGATIVELENGTH: invalid value '-2' in 'ffixed-line-length=', value must be 'none' or a positive integer
!-----------------------------------------
! EXPECTED OUTPUT WITH LENGTH LESS THAN 7
!-----------------------------------------
! INVALIDLENGTH: invalid value '3' in 'ffixed-line-length=','value must be at least seven'
! INVALIDLENGTH: invalid value '3' in 'ffixed-line-length=', value must be '7' or greater
!---------------------------------------
! EXPECTED OUTPUT WITH UNLIMITED LENGTH