Failure>
calculate_result_and_manifest_key(Context& ctx,
const Args& args,
- Args& preprocessor_args,
Hash& hash,
- bool direct_mode)
+ Args* preprocessor_args)
{
+ bool direct_mode = !preprocessor_args;
bool found_ccbin = false;
hash.hash_delimiter("cache entry version");
result_key = get_result_key_from_manifest(ctx, *manifest_key);
}
} else if (ctx.args_info.arch_args.empty()) {
- const auto digest = get_result_key_from_cpp(ctx, preprocessor_args, hash);
+ const auto digest = get_result_key_from_cpp(ctx, *preprocessor_args, hash);
if (!digest) {
return nonstd::make_unexpected(digest.error());
}
result_key = *digest;
LOG_RAW("Got result key from preprocessor");
} else {
- preprocessor_args.push_back("-arch");
+ preprocessor_args->push_back("-arch");
for (size_t i = 0; i < ctx.args_info.arch_args.size(); ++i) {
- preprocessor_args.push_back(ctx.args_info.arch_args[i]);
- const auto digest = get_result_key_from_cpp(ctx, preprocessor_args, hash);
+ preprocessor_args->push_back(ctx.args_info.arch_args[i]);
+ const auto digest =
+ get_result_key_from_cpp(ctx, *preprocessor_args, hash);
if (!digest) {
return nonstd::make_unexpected(digest.error());
}
if (i != ctx.args_info.arch_args.size() - 1) {
result_key = std::nullopt;
}
- preprocessor_args.pop_back();
+ preprocessor_args->pop_back();
}
- preprocessor_args.pop_back();
+ preprocessor_args->pop_back();
}
if (result_key) {
if (ctx.config.direct_mode()) {
LOG_RAW("Trying direct lookup");
- Args dummy_args;
MTR_BEGIN("hash", "direct_hash");
const auto result_and_manifest_key = calculate_result_and_manifest_key(
- ctx, args_to_hash, dummy_args, direct_hash, true);
+ ctx, args_to_hash, direct_hash, nullptr);
MTR_END("hash", "direct_hash");
if (!result_and_manifest_key) {
return nonstd::make_unexpected(result_and_manifest_key.error());
MTR_BEGIN("hash", "cpp_hash");
const auto result_and_manifest_key = calculate_result_and_manifest_key(
- ctx, args_to_hash, processed.preprocessor_args, cpp_hash, false);
+ ctx, args_to_hash, cpp_hash, &processed.preprocessor_args);
MTR_END("hash", "cpp_hash");
if (!result_and_manifest_key) {
return nonstd::make_unexpected(result_and_manifest_key.error());
result_key = result_and_manifest_key->first;
// calculate_result_and_manifest_key always returns a non-nullopt result_key
- // if the last argument (direct_mode) is false.
+ // in preprocessor mode (non-nullptr last argument).
ASSERT(result_key);
if (result_key_from_manifest && result_key_from_manifest != result_key) {