Repository navigation
feat: data-flow framework and constant propagation - #18
Merged
Merged
Conversation
4 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Phase 4 of
docs/architecture.md: the generic data-flow framework and abstract values (§18, §37dataflow/andabstract/, §38 Phase 4).test: define data-flow framework and constant propagation behavior), implementation follows.dataflow/lattice.py:BOTTOM,TOP, theLatticeprotocol and aFlatLatticewhose elements are compared by type as well as value, so1andTruestay distinct constants.dataflow/solver.py: a worklist solver over a CFG, forward or backward. A problem receives the states arriving on the executable incoming edges of a block and returns the states it sends along outgoing edges; edges it does not return are pruned. Blocks are revisited only when an incoming edge changes; unreachable code is never visited.abstract/values.py:AbstractValuewith a flat constant, a set of possible types and the truthiness that follows. Taints, ranges, string constraints and nullability will extend this record with their analyses.abstract/constants.py:ConstantPropagation(abstract.constants), the reference client validating the framework and the Analysis Manager end to end. It folds pure operations on safe constants (arithmetic, comparisons, unary operators), refuses unbounded ones (**, shifts,str * int), joins at phis over executable edges only, prunes the branches a constant condition never takes, and keeps types when constants are lost, so a loop counter stays anint.abstractnow sits abovedataflow.Not in this PR: ranges, string constraints and nullability (Phase 8), and CLI reporting of facts.
Closes #17