forked from typetools/checker-framework
-
Notifications
You must be signed in to change notification settings - Fork 11
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
Introduce bottom store to improve dataflow analysis #167
Open
d367wang
wants to merge
27
commits into
opprop:master
Choose a base branch
from
d367wang:bottom-store
base: master
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.
Open
Changes from 2 commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
7e91f46
initial bottom-store implementation
d367wang 2237641
Merge branch 'master' of https://github.com/opprop/checker-framework …
d367wang 6ec3d77
Merge branch 'master' of https://github.com/opprop/checker-framework …
d367wang 0122edf
undo import *
d367wang c276efa
fix compile error
d367wang cceadf7
fix bug
d367wang 81c8059
add lock bottom store; remove FPs involving if(true/false)
d367wang 887a888
NullnessBottom.getValue returns two qualifiers
d367wang 9af8f2e
xxxBottomStore.getValue returns abstract value with bottom annotations
d367wang 0a4adad
remove @Nullable on xxxBottomStore.getValue
d367wang 6775dfa
fix bug
d367wang 68b238b
make bottom-store logic coherent to CFAbstract classes
d367wang 826d25a
Merge branch 'master' of https://github.com/opprop/checker-framework …
d367wang d6ddb82
adapt expected files
d367wang ee35b60
Merge branch 'master' of https://github.com/opprop/checker-framework …
d367wang 080ff48
remove BOTH_TO_THEN and BOTH_TO_ELSE
d367wang d70186b
fix bug and refactor
d367wang 5b616d3
hack CFAbastractValue.combineOneAnnotation
d367wang e83dea7
only use bottom store when the boolean literal is a condition on its own
d367wang ea69c0a
suppress intern error
d367wang 2e03227
adapt expected error
d367wang 7408317
change bottom value for lock type system
d367wang 44c97a7
fix bug in bottom store, to resolve the must-call case
d367wang a6509e5
adapt bottom value for lock type system
d367wang 9041117
no insertion to bottom store
d367wang 40a27ca
add javadoc
d367wang a131f41
apply default to void methodreturns
d367wang File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
104 changes: 104 additions & 0 deletions
104
checker/src/main/java/org/checkerframework/checker/nullness/KeyForBottomStore.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
package org.checkerframework.checker.nullness; | ||
|
||
import org.checkerframework.checker.nullness.qual.Nullable; | ||
import org.checkerframework.dataflow.analysis.FlowExpressions; | ||
import org.checkerframework.dataflow.cfg.node.ArrayAccessNode; | ||
import org.checkerframework.dataflow.cfg.node.FieldAccessNode; | ||
import org.checkerframework.dataflow.cfg.node.LocalVariableNode; | ||
import org.checkerframework.dataflow.cfg.node.MethodInvocationNode; | ||
import org.checkerframework.dataflow.cfg.node.Node; | ||
import org.checkerframework.dataflow.cfg.node.ThisLiteralNode; | ||
import org.checkerframework.framework.flow.CFAbstractAnalysis; | ||
import org.checkerframework.framework.type.AnnotatedTypeFactory; | ||
|
||
import javax.lang.model.element.AnnotationMirror; | ||
import javax.lang.model.type.TypeMirror; | ||
|
||
public class KeyForBottomStore extends KeyForStore { | ||
public KeyForBottomStore( | ||
CFAbstractAnalysis<KeyForValue, KeyForStore, ?> analysis, boolean sequentialSemantics) { | ||
super(analysis, sequentialSemantics); | ||
} | ||
|
||
@Override | ||
public boolean isBottom() { | ||
return true; | ||
} | ||
|
||
@Override | ||
public KeyForStore copy() { | ||
// throw new BugInCF("Copying of bottom store is not allowed."); | ||
return this; | ||
} | ||
|
||
/** The LUB of a bottom store and a second store is the second store */ | ||
@Override | ||
public KeyForStore leastUpperBound(KeyForStore other) { | ||
return other; | ||
} | ||
|
||
@Override | ||
public KeyForStore widenedUpperBound(KeyForStore previous) { | ||
return previous; | ||
} | ||
|
||
@Override | ||
public boolean equals(@Nullable Object o) { | ||
return this == o; | ||
} | ||
|
||
@Nullable @Override | ||
public KeyForValue getValue(FlowExpressions.Receiver expr) { | ||
return null; | ||
} | ||
|
||
@Nullable @Override | ||
public KeyForValue getValue(FieldAccessNode n) { | ||
return null; | ||
} | ||
|
||
@Nullable @Override | ||
public KeyForValue getValue(MethodInvocationNode n) { | ||
return null; | ||
} | ||
|
||
@Nullable @Override | ||
public KeyForValue getValue(ArrayAccessNode n) { | ||
return null; | ||
} | ||
|
||
@Nullable @Override | ||
public KeyForValue getValue(LocalVariableNode n) { | ||
return null; | ||
} | ||
|
||
@Nullable @Override | ||
public KeyForValue getValue(ThisLiteralNode n) { | ||
return null; | ||
} | ||
|
||
@Override | ||
public void updateForMethodCall( | ||
MethodInvocationNode n, AnnotatedTypeFactory atypeFactory, KeyForValue val) {} | ||
|
||
@Override | ||
public void insertValue(FlowExpressions.Receiver r, AnnotationMirror a) {} | ||
|
||
@Override | ||
public void insertOrRefine(FlowExpressions.Receiver r, AnnotationMirror newAnno) {} | ||
|
||
@Override | ||
public void insertValue(FlowExpressions.Receiver r, @Nullable KeyForValue value) {} | ||
|
||
@Override | ||
public void insertThisValue(AnnotationMirror a, TypeMirror underlyingType) {} | ||
|
||
@Override | ||
public void replaceValue(FlowExpressions.Receiver r, @Nullable KeyForValue value) {} | ||
|
||
@Override | ||
public void clearValue(FlowExpressions.Receiver r) {} | ||
|
||
@Override | ||
public void updateForAssignment(Node n, @Nullable KeyForValue val) {} | ||
} |
This file contains 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
112 changes: 112 additions & 0 deletions
112
checker/src/main/java/org/checkerframework/checker/nullness/NullnessBottomStore.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
package org.checkerframework.checker.nullness; | ||
|
||
import org.checkerframework.checker.nullness.qual.Nullable; | ||
import org.checkerframework.dataflow.analysis.FlowExpressions; | ||
import org.checkerframework.dataflow.cfg.node.ArrayAccessNode; | ||
import org.checkerframework.dataflow.cfg.node.FieldAccessNode; | ||
import org.checkerframework.dataflow.cfg.node.LocalVariableNode; | ||
import org.checkerframework.dataflow.cfg.node.MethodInvocationNode; | ||
import org.checkerframework.dataflow.cfg.node.Node; | ||
import org.checkerframework.dataflow.cfg.node.ThisLiteralNode; | ||
import org.checkerframework.framework.flow.CFAbstractAnalysis; | ||
import org.checkerframework.framework.type.AnnotatedTypeFactory; | ||
|
||
import javax.lang.model.element.AnnotationMirror; | ||
import javax.lang.model.type.TypeMirror; | ||
|
||
public class NullnessBottomStore extends NullnessStore { | ||
private final AnnotationMirror NONNULL; | ||
|
||
public NullnessBottomStore( | ||
CFAbstractAnalysis<NullnessValue, NullnessStore, ?> analysis, | ||
boolean sequentialSemantics) { | ||
super(analysis, sequentialSemantics); | ||
NONNULL = ((NullnessAnnotatedTypeFactory) analysis.getTypeFactory()).NONNULL; | ||
} | ||
|
||
@Override | ||
public boolean isBottom() { | ||
return true; | ||
} | ||
|
||
@Override | ||
public NullnessStore copy() { | ||
// throw new BugInCF("Copying of bottom store is not allowed."); | ||
return this; | ||
} | ||
|
||
/** The LUB of a bottom store and a second store is the second store */ | ||
@Override | ||
public NullnessStore leastUpperBound(NullnessStore other) { | ||
return other; | ||
} | ||
|
||
@Override | ||
public NullnessStore widenedUpperBound(NullnessStore previous) { | ||
return previous; | ||
} | ||
|
||
@Override | ||
public boolean equals(@Nullable Object o) { | ||
return this == o; | ||
} | ||
|
||
@Nullable @Override | ||
public NullnessValue getValue(FlowExpressions.Receiver expr) { | ||
return analysis.createSingleAnnotationValue(NONNULL, expr.getType()); | ||
} | ||
|
||
private NullnessValue getBottomValue(Node n) { | ||
return analysis.createSingleAnnotationValue(NONNULL, n.getType()); | ||
} | ||
|
||
@Nullable @Override | ||
public NullnessValue getValue(FieldAccessNode n) { | ||
return getBottomValue(n); | ||
} | ||
|
||
@Nullable @Override | ||
public NullnessValue getValue(MethodInvocationNode n) { | ||
return getBottomValue(n); | ||
} | ||
|
||
@Nullable @Override | ||
public NullnessValue getValue(ArrayAccessNode n) { | ||
return getBottomValue(n); | ||
} | ||
|
||
@Nullable @Override | ||
public NullnessValue getValue(LocalVariableNode n) { | ||
return getBottomValue(n); | ||
} | ||
|
||
@Nullable @Override | ||
public NullnessValue getValue(ThisLiteralNode n) { | ||
return getBottomValue(n); | ||
} | ||
|
||
@Override | ||
public void updateForMethodCall( | ||
MethodInvocationNode n, AnnotatedTypeFactory atypeFactory, NullnessValue val) {} | ||
|
||
@Override | ||
public void insertValue(FlowExpressions.Receiver r, AnnotationMirror a) {} | ||
|
||
@Override | ||
public void insertOrRefine(FlowExpressions.Receiver r, AnnotationMirror newAnno) {} | ||
|
||
@Override | ||
public void insertValue(FlowExpressions.Receiver r, @Nullable NullnessValue value) {} | ||
|
||
@Override | ||
public void insertThisValue(AnnotationMirror a, TypeMirror underlyingType) {} | ||
|
||
@Override | ||
public void replaceValue(FlowExpressions.Receiver r, @Nullable NullnessValue value) {} | ||
|
||
@Override | ||
public void clearValue(FlowExpressions.Receiver r) {} | ||
|
||
@Override | ||
public void updateForAssignment(Node n, @Nullable NullnessValue val) {} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import org.checkerframework.checker.nullness.qual.Nullable; | ||
|
||
public class IfTrue { | ||
|
||
Object foo(@Nullable Object myObj, boolean x) { | ||
if (x) { | ||
myObj = new Object(); | ||
} | ||
return myObj; | ||
} | ||
} |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.
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.
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.
Why do we need
boolean x
?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.
Thanks for pointing out! I need to add another case using
x
as the condition.