Reuse and work accounting (RFC 0020)
AnalysisStats is a Clang-free invocation-owned counter/timer sink. The frontend
shares it with function and context analyses and writes the explicit JSON output
atomically. No counter affects the model’s joins or coverage decisions.
SummaryStore records dependencies in every active analysis frame. Context hits
inherit their dependencies into callers. Function and global-fact updates remove
only affected contexts; revision snapshots also detect changes during a context’s
own computation. Invalidated nodes remain alive until the outermost applying
analysis finishes. A preparation cache is owned by the retained AST and contains
CFGs, lexical lifetimes and liveness with its nonreturning-block assumptions.
Place IDs, initial states, call effects and diagnostics are per-run data.
ProgramDatabase publishes one immutable generic contract for callable,
external-definition and indirect-candidate lookup where their contents agree.
Copied databases share those publications. Duplicate-definition and candidate
joins construct private replacements, preserving other indexes and earlier
database generations. Renumbering happens before publication; checkpoints still
retain every lookup namespace. Completed dataflow results move into publication
instead of copying their owned maps.
Within one unit addition, indirect candidates of a shared type accumulate in
a private group before publication, avoiding repeated copies of its growing
contract. Whole-program members with matching global numbering move their
complete export sets into place; remapping uses the existing namespace rules.
Completed cache candidates retain replay metadata beside a single export set.
Checkpoint publication temporarily takes those exports and restores them after
the write, including on failure, before any later analysis runs.
CompilationDatabaseUnit and the compiler’s Cc1Unit retain an AST during
whole-program iteration. The frontend’s common analysis/replay path attaches a
fresh reporting consumer, the current program database and warning controls.
The retained-unit diagnostic consumer writes through a private 16 KiB stderr
buffer and flushes after each diagnostic. It preserves Clang’s rendered output,
color policy and prompt delivery without changing global stream buffering.
Compact report interning reuses immutable call paths through a 1,024-entry memo
that retains its backing storage. Eviction repeats interning without changing
first-use table identifiers or report semantics.
Call checking resolves an erased argument holder only when its static type
cannot supply an expected object view; recovery is consumed within that one
validation. Trust classification reuses the ledger’s exact trusted-origin
projection. Diagnostic identities scan plain ASCII in bounded words and retain
the byte-wise UTF-8/escape rules for every other input.
SafetyLedger copies share storage until mutation. Semantic equality compares
operation identity, outcome and exhaustion; diagnostic wording and route choice
have a separate equality operation.
AnalysisCache stores complete unit results only after their program component
settles. Private format 2 separates shared obligation/path/ledger tables from
canonical sidecar records carrying the remaining export metadata. It checks
producer round trips in the same global namespace and validates all table
references before restoring contracts. Diagnostics and dependencies use bounded
JSON records. The cache format is independent of the sidecar format. Input validation preprocesses an effective
invocation; imported validation projects observed symbols plus conservative
global facts and requests. The guide describes cache
misses and compact report version 3.
Sidecar format 16 introduced checked-preprocessing. The compiler
computes it from the effective preprocessor invocation before compiling, then
recomputes it from the recorded command before validating any checked link
input. This catches new conditional-include targets as well as changed loaded
files. Unsupported or unverifiable preprocessing cannot substantiate checked
object replay. RFC 0021 extended the records with summary format 16 and
sidecar format 17; the preprocessing and executable bindings still apply.