MCPcopy Create free account
hub / github.com/KhronosGroup/SPIRV-Tools / ParseOconfigFlag

Function ParseOconfigFlag

tools/opt/opt.cpp:667–699  ·  view source on GitHub ↗

Parses and handles the -Oconfig flag. |prog_name| contains the name of the spirv-opt binary (used to build a new argv vector for the recursive invocation to ParseFlags). |opt_flag| contains the -Oconfig=FILENAME flag. |optimizer|, |in_file|, |out_file|, |validator_options|, and |optimizer_options| are as in ParseFlags. This returns the same OptStatus instance returned by ParseFlags.

Source from the content-addressed store, hash-verified

665//
666// This returns the same OptStatus instance returned by ParseFlags.
667OptStatus ParseOconfigFlag(const char* prog_name, const char* opt_flag,
668 spvtools::Optimizer* optimizer, const char** in_file,
669 const char** out_file,
670 spvtools::ValidatorOptions* validator_options,
671 spvtools::OptimizerOptions* optimizer_options) {
672 std::vector<std::string> flags;
673 flags.push_back(prog_name);
674
675 std::vector<std::string> file_flags;
676 if (!ReadFlagsFromFile(opt_flag, &file_flags)) {
677 spvtools::Error(opt_diagnostic, nullptr, {},
678 "Could not read optimizer flags from configuration file");
679 return {OPT_STOP, 1};
680 }
681 flags.insert(flags.end(), file_flags.begin(), file_flags.end());
682
683 const char** new_argv = new const char*[flags.size()];
684 for (size_t i = 0; i < flags.size(); i++) {
685 if (flags[i].find("-Oconfig=") != std::string::npos) {
686 spvtools::Error(
687 opt_diagnostic, nullptr, {},
688 "Flag -Oconfig= may not be used inside the configuration file");
689 return {OPT_STOP, 1};
690 }
691 new_argv[i] = flags[i].c_str();
692 }
693
694 auto ret_val =
695 ParseFlags(static_cast<int>(flags.size()), new_argv, optimizer, in_file,
696 out_file, validator_options, optimizer_options);
697 delete[] new_argv;
698 return ret_val;
699}
700
701// Canonicalize the flag in |argv[argi]| of the form '--pass arg' into
702// '--pass=arg'. The optimizer only accepts arguments to pass names that use the

Callers 1

ParseFlagsFunction · 0.85

Calls 9

ReadFlagsFromFileFunction · 0.85
c_strMethod · 0.80
ParseFlagsFunction · 0.70
ErrorFunction · 0.50
push_backMethod · 0.45
insertMethod · 0.45
endMethod · 0.45
beginMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected