Handle parse failure for setting spec constants

This commit is contained in:
David Neto 2016-09-22 17:09:34 -04:00
parent a6ef1ea29e
commit c6b23f8237

View File

@ -54,8 +54,8 @@ Options:
when possible.
--set-spec-const-default-value "<spec id>:<default value> ..."
Set the default values of the specialization constants with
<spec id>-<default value> pairs specified in a double-quoted
string. <spec id>-<default value> pairs must be separated by
<spec id>:<default value> pairs specified in a double-quoted
string. <spec id>:<default value> pairs must be separated by
blank spaces, and in each pair, spec id and default value must
be separated with colon ':' without any blank spaces in between.
e.g.: --set-spec-const-default-value "1:100 2:400"
@ -103,11 +103,18 @@ int main(int argc, char** argv) {
auto spec_ids_vals =
opt::SetSpecConstantDefaultValuePass::ParseDefaultValuesString(
argv[argi]);
if (!spec_ids_vals) {
fprintf(stderr,
"error: Invalid argument for "
"--set-spec-const-default-value: %s\n",
argv[argi]);
return 1;
}
pass_manager.AddPass<opt::SetSpecConstantDefaultValuePass>(
std::move(*spec_ids_vals));
} else {
fprintf(stderr,
"error: Expect a string of <spec id>-<default value> pairs.");
"error: Expected a string of <spec id>:<default value> pairs.");
return 1;
}
} else if (0 == strcmp(cur_arg, "--freeze-spec-const")) {