-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Shared/Java: Add shared Guards library and switch Java to use it. #19573
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
aschackmull
wants to merge
14
commits into
github:main
Choose a base branch
from
aschackmull:guardslib
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
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
} | ||
|
||
private module LogicInput_v2 implements GuardsImpl::LogicInputSig { | ||
private import semmle.code.java.dataflow.SSA as SSA |
Check warning
Code scanning / CodeQL
Names only differing by case Warning
SSA is only different by casing from Ssa that is used elsewhere for modules.
Comment on lines
+1
to
+49
/** | ||
* Provides classes and predicates for determining "guard-controls" | ||
* relationships. | ||
* | ||
* In their most general form, these relate a guard expression, a value, and a | ||
* basic block, and state that execution of the basic block implies that | ||
* control flow must have passed through the guard in order to reach the basic | ||
* block, and when it did, the guard evaluated to the given value. | ||
* | ||
* For example, in `if (x == 0) { A }`, the guard `x == 0` evaluating to `true` | ||
* controls the basic block `A`, in this case because the true branch dominates | ||
* `A`, but more elaborate controls-relationships may also hold. | ||
* For example, in | ||
* ``` | ||
* int sz = a != null ? a.length : 0; | ||
* if (sz != 0) { | ||
* // this block is controlled by: | ||
* // sz != 0 evaluating to true | ||
* // sz evaluating to not 0 | ||
* // a.length evaluating to not 0 | ||
* // a != null evaluating to true | ||
* // a evaluating to not null | ||
* } | ||
* ``` | ||
* | ||
* The provided predicates are separated into general "controls" predicates and | ||
* "directly controls" predicates. The former use all possible implication | ||
* logic as described above, whereas the latter only use control flow dominance | ||
* of the corresponding conditional successor edges. | ||
* | ||
* In some cases, a guard may have a successor edge that can be relevant for | ||
* controlling the input to an SSA phi node, but does not dominate the | ||
* preceeding block. To support this, the `hasBranchEdge` and | ||
* `controlsBranchEdge` predicates are provided, where the former only uses the | ||
* control flow graph similar to the `directlyControls` predicate, and the | ||
* latter uses the full implication logic. | ||
* | ||
* All of these predicates are also available in the more general form that refers | ||
* to `GuardValue`s instead of `boolean`s. | ||
* | ||
* The implementation is nested in two parameterized modules intended to | ||
* facilitate multiple instantiations of the nested module with different | ||
* precision levels. For example, more implications are available if the result | ||
* of Range Analysis is available, but Range Analysis depends on Guards. This | ||
* allows an initial instantiation of the `Logic` module without Range Analysis | ||
* that can be used as input to Range Analysis, and a second instantiation | ||
* using the result of Range Analysis to provide a final and more complete | ||
* controls relation. | ||
*/ |
Check warning
Code scanning / CodeQL
Misspelling Warning
This comment contains the common misspelling 'preceeding', which should instead be 'preceding'.
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.
No description provided.