-
Notifications
You must be signed in to change notification settings - Fork 355
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
Boolean variables in dataflow #6797
base: master
Are you sure you want to change the base?
Conversation
@smillst Could you please add the missing documentation? Also, a test is failing. |
@@ -71,6 +73,71 @@ public abstract class CFAbstractStore<V extends CFAbstractValue<V>, S extends CF | |||
/** Information collected about local variables (including method parameters). */ | |||
protected final Map<LocalVariable, V> localVariableValues; | |||
|
|||
/** Stores after boolean variable assignment. */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wound find this comment more useful if it said more about the semantics, rather than when the field is first set. The map is from boolean local variables, and the mapped-to store indicates facts that are true depending on whether the boolean local variable is true or false.
protected final Map<LocalVariable, BooleanVarStore<V, S>> booleanVarStores; | ||
|
||
/** | ||
* An object that contains the then and else store after a boolean variable assignment. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here too, I think that "after a boolean variable assignment" is not the most important thing to document.
It would be helpful, here, to discuss the goal and the design.
BooleanVarStore(S thenStore, S elseStore) { | ||
this.thenStore = thenStore.copy(); | ||
this.elseStore = elseStore.copy(); | ||
thenStore.booleanVarStores.clear(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be helpful to document the reason that these substores are cleared.
@@ -1186,6 +1286,24 @@ private S upperBound(S other, boolean shouldWiden) { | |||
} | |||
} | |||
|
|||
for (Map.Entry<LocalVariable, BooleanVarStore<V, S>> e : other.booleanVarStores.entrySet()) { | |||
// If a local variable appears in just one store, then the other store implicitly contains |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here and above, can you remark on whether this is done for correctness, or performance, or as a heuristic?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This pull request looks good overall -- thanks!
However, it needs more documentation, both of its goal and its implementation.
Linking this comment on the previous PR so it doesn't get lost (regarding overhead): |
This implementation isn't working as expected. In particular, there are unexpected errors in
checker/tests/nullness/Issue406.java
.Fixes #406.