You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: introduce Provenance type and migrate metadata from FileRange (#1140)
Fixes#1139
Introduces a `Provenance` type that fully replaces `FileRange` and
`SourceRange` as the canonical way to store source locations in
metadata. This structurally eliminates the "SourceRange without file
name" problem.
The `Provenance` type has two constructors:
- `Provenance.loc uri range` — a real source location (always requires
both URI and range)
- `Provenance.synthesized origin` — a node created programmatically,
with a `SynthesizedOrigin` inductive type
A `SynthesizedOrigin` inductive enforces that only canonical origins are
used (`smtEncode`, `nondetIte`, `laurelParse`, `laurel`, `laurelToCore`,
`structuredToUnstructured`), preventing typos and duplicates at the type
level.
Key changes:
- The `.fileRange` variant is removed from `MetaDataElem.Value` — all
metadata values now use `.provenance` exclusively
- `MetaData.ofSourceRange` emits only a provenance element
- `getProvenance` is the single source of truth for reading source
locations from metadata
- `setCallSiteFileRange` works directly with `Provenance` instead of
roundtripping through `FileRange`
- `getFileRange` delegates to `getProvenance` for extraction
- `FileRange.unknown` and `SourceRange.none` eliminated from metadata
construction
- SMT DDM translator uses `smtAnn` combinator to reduce annotation
boilerplate
- SARIF output uses `getFileRange` (which reads provenance)
`FileRange` remains as a utility struct for extraction and formatting
(e.g., in `DiagnosticModel`), but is no longer a metadata value type.
Existing tests pass unchanged.
## Follow-up
- Migrate the B3, Boole, and Python grammar ASTs from using
`SourceRange` as their annotation type parameter to `Provenance`. This
would allow combining multiple files at the AST level and enable proper
provenance tracking through translation passes.
0 commit comments