}
bool
-process_profiling_option(Context& ctx, const std::string& arg)
+process_profiling_option(const Context& ctx,
+ ArgsInfo& args_info,
+ const std::string& arg)
{
static const std::vector<std::string> known_simple_options = {
"-fprofile-correction",
if (util::starts_with(arg, "-fprofile-dir=")) {
new_profile_path = arg.substr(arg.find('=') + 1);
} else if (arg == "-fprofile-generate" || arg == "-fprofile-instr-generate") {
- ctx.args_info.profile_generate = true;
+ args_info.profile_generate = true;
if (ctx.config.compiler_type() == CompilerType::clang) {
new_profile_path = ".";
} else {
}
} else if (util::starts_with(arg, "-fprofile-generate=")
|| util::starts_with(arg, "-fprofile-instr-generate=")) {
- ctx.args_info.profile_generate = true;
+ args_info.profile_generate = true;
new_profile_path = arg.substr(arg.find('=') + 1);
} else if (arg == "-fprofile-use" || arg == "-fprofile-instr-use"
|| arg == "-fprofile-sample-use" || arg == "-fbranch-probabilities"
|| arg == "-fauto-profile") {
new_profile_use = true;
- if (ctx.args_info.profile_path.empty()) {
+ if (args_info.profile_path.empty()) {
new_profile_path = ".";
}
} else if (util::starts_with(arg, "-fprofile-use=")
}
if (new_profile_use) {
- if (ctx.args_info.profile_use) {
+ if (args_info.profile_use) {
LOG_RAW("Multiple profiling options not supported");
return false;
}
- ctx.args_info.profile_use = true;
+ args_info.profile_use = true;
}
if (!new_profile_path.empty()) {
- ctx.args_info.profile_path = new_profile_path;
- LOG("Set profile directory to {}", ctx.args_info.profile_path);
+ args_info.profile_path = new_profile_path;
+ LOG("Set profile directory to {}", args_info.profile_path);
}
- if (ctx.args_info.profile_generate && ctx.args_info.profile_use) {
+ if (args_info.profile_generate && args_info.profile_use) {
// Too hard to figure out what the compiler will do.
LOG_RAW("Both generating and using profile info, giving up");
return false;
}
optional<Statistic>
-process_arg(Context& ctx,
+process_arg(const Context& ctx,
+ ArgsInfo& args_info,
+ Config& config,
Args& args,
size_t& args_index,
ArgumentProcessingState& state)
{
- ArgsInfo& args_info = ctx.args_info;
- Config& config = ctx.config;
-
size_t& i = args_index;
// The user knows best: just swallow the next arg.
}
if (util::starts_with(args[i], "-MQ") || util::starts_with(args[i], "-MT")) {
- ctx.args_info.dependency_target_specified = true;
+ args_info.dependency_target_specified = true;
if (args[i].size() == 3) {
// -MQ arg or -MT arg
if (util::starts_with(args[i], "-fprofile-")
|| util::starts_with(args[i], "-fauto-profile")
|| args[i] == "-fbranch-probabilities") {
- if (!process_profiling_option(ctx, args[i])) {
+ if (!process_profiling_option(ctx, args_info, args[i])) {
// The failure is logged by process_profiling_option.
return Statistic::unsupported_compiler_option;
}
optional<Statistic> argument_error;
for (size_t i = 1; i < args.size(); i++) {
- const auto error = process_arg(ctx, args, i, state);
+ const auto error =
+ process_arg(ctx, ctx.args_info, ctx.config, args, i, state);
if (error && !argument_error) {
argument_error = error;
}