Skip to content

clore::extract::ensure_cache_key

Owner: Module extract:compiler

Declaration: extract/compiler.cppm:60

Definition: extract/compiler.cppm:225

Declaration: Namespace clore::extract

Implementation

cpp
auto ensure_cache_key(CompileEntry& entry) -> void {
    ensure_cache_key_impl(entry);
}

函数 clore::extract::ensure_cache_key 完全委托给内部的 ensure_cache_key_impl,后者负责为给定的 CompileEntry 计算并设置 cache_key 字段。实现流程首先调用 normalize_entry_file 获取规范化路径,然后通过 sanitize_driver_arguments 清理参数列表,并尝试用 parse_compiler_invocation 解析出 CompilerInvocation,从中提取 frontend_inputs 并调用 try_hash_source_file 计算 source_hash。接着利用 build_compile_signature(内部委托给 build_compile_signature_impl)生成最终的签名值,此过程还会查询 toolchain_cache(通过 query_toolchain_cached)并可能加载编译数据库(load_compdb)以补充缺失上下文,最终将签名写入 entry.cache_key 以确保每个条目拥有唯一的缓存标识。

Side Effects

  • Modifies the CompileEntry by setting its cache key.

Reads From

  • Parameter entry (reference to CompileEntry).

Writes To

  • Parameter entry (the CompileEntry object is mutated).

Usage Patterns

  • Called by query_toolchain_cached before attempting to use cached toolchain information to ensure the entry has a valid cache key.

Calls

  • function clore::extract::ensure_cache_key_impl

Called By

  • function clore::extract::query_toolchain_cached