From: David Neto Date: Thu, 22 Sep 2016 21:09:34 +0000 (-0400) Subject: Handle parse failure for setting spec constants X-Git-Tag: upstream/2018.6~1027 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c6b23f823750fed58945ed0a47e1d65d9db92fd2;p=platform%2Fupstream%2FSPIRV-Tools.git Handle parse failure for setting spec constants --- diff --git a/tools/opt/opt.cpp b/tools/opt/opt.cpp index 38a6c27..b317f8e 100644 --- a/tools/opt/opt.cpp +++ b/tools/opt/opt.cpp @@ -54,8 +54,8 @@ Options: when possible. --set-spec-const-default-value ": ..." Set the default values of the specialization constants with - - pairs specified in a double-quoted - string. - pairs must be separated by + : pairs specified in a double-quoted + string. : 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( std::move(*spec_ids_vals)); } else { fprintf(stderr, - "error: Expect a string of - pairs."); + "error: Expected a string of : pairs."); return 1; } } else if (0 == strcmp(cur_arg, "--freeze-spec-const")) {