Skip to content

Commit 80ce9ec

Browse files
authored
Merge branch 'master' into bugfix/wpi-loop-unknowninitialization
2 parents f057894 + cb2b57b commit 80ce9ec

17 files changed

Lines changed: 86 additions & 34 deletions

File tree

checker-qual-android/build.gradle

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,19 @@ task copySources(type: Copy) {
1919

2020
into file(layout.buildDirectory.dir("generated/sources/main/java"))
2121

22-
fileMode(0555)
22+
filePermissions {
23+
user {
24+
read = true
25+
write = true
26+
execute = true
27+
}
28+
group {
29+
read = true
30+
write = true
31+
execute = true
32+
}
33+
other.read = true
34+
}
2335
}
2436

2537
sourceSets {

checker-qual/src/main/java/org/checkerframework/framework/qual/DefaultQualifier.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
* @checker_framework.manual #defaults Default qualifier for unannotated types
3535
*/
3636
@Documented
37-
@Retention(RetentionPolicy.SOURCE)
37+
@Retention(RetentionPolicy.RUNTIME)
3838
@Target({
3939
ElementType.PACKAGE,
4040
ElementType.TYPE,

checker/src/main/java/org/checkerframework/checker/optional/OptionalTransfer.java

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,15 @@
2222
import org.checkerframework.framework.flow.CFStore;
2323
import org.checkerframework.framework.flow.CFTransfer;
2424
import org.checkerframework.framework.flow.CFValue;
25-
import org.checkerframework.framework.type.AnnotatedTypeFactory;
2625
import org.checkerframework.javacutil.AnnotationBuilder;
2726
import org.checkerframework.javacutil.TreeUtils;
2827

2928
/** The transfer function for the Optional Checker. */
3029
public class OptionalTransfer extends CFTransfer {
3130

31+
/** The {@link OptionalAnnotatedTypeFactory} instance for this transfer class. */
32+
private final OptionalAnnotatedTypeFactory optionalTypeFactory;
33+
3234
/** The @{@link Present} annotation. */
3335
private final AnnotationMirror PRESENT;
3436

@@ -38,20 +40,17 @@ public class OptionalTransfer extends CFTransfer {
3840
/** The element for java.util.Optional.ifPresentOrElse(), or null. */
3941
private final @Nullable ExecutableElement optionalIfPresentOrElse;
4042

41-
/** The type factory associated with this transfer function. */
42-
private final AnnotatedTypeFactory atypeFactory;
43-
4443
/**
4544
* Create an OptionalTransfer.
4645
*
4746
* @param analysis the Optional Checker instance
4847
*/
4948
public OptionalTransfer(CFAbstractAnalysis<CFValue, CFStore, CFTransfer> analysis) {
5049
super(analysis);
51-
atypeFactory = analysis.getTypeFactory();
52-
Elements elements = atypeFactory.getElementUtils();
50+
optionalTypeFactory = (OptionalAnnotatedTypeFactory) analysis.getTypeFactory();
51+
Elements elements = optionalTypeFactory.getElementUtils();
5352
PRESENT = AnnotationBuilder.fromClass(elements, Present.class);
54-
ProcessingEnvironment env = atypeFactory.getProcessingEnv();
53+
ProcessingEnvironment env = optionalTypeFactory.getProcessingEnv();
5554
optionalIfPresent = TreeUtils.getMethod("java.util.Optional", "ifPresent", 1, env);
5655
optionalIfPresentOrElse =
5756
TreeUtils.getMethodOrNull("java.util.Optional", "ifPresentOrElse", 2, env);
@@ -70,7 +69,7 @@ public CFStore initialStore(UnderlyingAST underlyingAST, List<LocalVariableNode>
7069
LambdaExpressionTree lambdaTree = cfgLambda.getLambdaTree();
7170
List<? extends VariableTree> lambdaParams = lambdaTree.getParameters();
7271
if (lambdaParams.size() == 1) {
73-
TreePath lambdaPath = atypeFactory.getPath(lambdaTree);
72+
TreePath lambdaPath = optionalTypeFactory.getPath(lambdaTree);
7473
Tree lambdaParent = lambdaPath.getParentPath().getLeaf();
7574
if (lambdaParent.getKind() == Tree.Kind.METHOD_INVOCATION) {
7675
MethodInvocationTree invok = (MethodInvocationTree) lambdaParent;

dataflow/src/main/java/org/checkerframework/dataflow/analysis/AbstractAnalysis.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,10 @@ protected boolean updateNodeValues(Node node, TransferResult<V, S> transferResul
468468
* @param b the block to add to {@link #worklist}
469469
*/
470470
protected void addToWorklist(Block b) {
471-
// TODO: use a more efficient way to check if b is already present
471+
// TODO: This costs linear (!) time. Use a more efficient way to check if b is already present.
472+
// Two possibilities:
473+
// * add unconditionally, and detect duplicates when removing from the queue.
474+
// * maintain a HashSet of the elements that are already in the queue.
472475
if (!worklist.contains(b)) {
473476
worklist.add(b);
474477
}

dataflow/src/main/java/org/checkerframework/dataflow/analysis/TransferInput.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@
1111
/**
1212
* {@code TransferInput} is used as the input type of the individual transfer functions of a {@link
1313
* ForwardTransferFunction} or a {@link BackwardTransferFunction}. It also contains a reference to
14-
* the node for which the transfer function will be applied.
14+
* the node to which the transfer function will be applied.
1515
*
1616
* <p>A {@code TransferInput} contains one or two stores. If two stores are present, one belongs to
17-
* 'then', and the other to 'else'.
17+
* "then", and the other to "else".
1818
*
1919
* @param <V> type of the abstract value that is tracked
2020
* @param <S> the store type used in the analysis
@@ -36,12 +36,12 @@ public class TransferInput<V extends AbstractValue<V>, S extends Store<S>> imple
3636
protected final @Nullable S store;
3737

3838
/**
39-
* The 'then' result store (or {@code null} if none is present). See invariant at {@link #store}.
39+
* The "then" result store (or {@code null} if none is present). See invariant at {@link #store}.
4040
*/
4141
protected final @Nullable S thenStore;
4242

4343
/**
44-
* The 'else' result store (or {@code null} if none is present). See invariant at {@link #store}.
44+
* The "else" result store (or {@code null} if none is present). See invariant at {@link #store}.
4545
*/
4646
protected final @Nullable S elseStore;
4747

@@ -64,8 +64,8 @@ public long getUid(@UnknownInitialization TransferInput<V, S> this) {
6464
*
6565
* @param node the corresponding node
6666
* @param store the regular result store, or {@code null} if none is present
67-
* @param thenStore the 'then' result store, or {@code null} if none is present
68-
* @param elseStore the 'else' result store, or {@code null} if none is present
67+
* @param thenStore the "then" result store, or {@code null} if none is present
68+
* @param elseStore the "else" result store, or {@code null} if none is present
6969
* @param analysis analysis the corresponding analysis class to get intermediate flow results
7070
*/
7171
private TransferInput(
@@ -166,7 +166,7 @@ protected TransferInput(TransferInput<V, S> from) {
166166
}
167167

168168
/**
169-
* Returns the abstract value of node {@code n}, which is required to be a 'sub-node' (that is, a
169+
* Returns the abstract value of node {@code n}, which is required to be a "sub-node" (that is, a
170170
* direct or indirect child) of the node this transfer input is associated with. Furthermore,
171171
* {@code n} cannot be a l-value node. Returns {@code null} if no value is available.
172172
*

dataflow/src/main/java/org/checkerframework/dataflow/cfg/node/ExplicitThisNode.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ public <R, P> R accept(NodeVisitor<R, P> visitor, P p) {
3232

3333
@Override
3434
public String toString() {
35-
return "this";
35+
if (Node.disambiguateOwner) {
36+
return "this{owner=" + type + "}";
37+
} else {
38+
return "this";
39+
}
3640
}
3741
}

dataflow/src/main/java/org/checkerframework/dataflow/cfg/node/FieldAccessNode.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import com.sun.source.tree.IdentifierTree;
44
import com.sun.source.tree.MemberSelectTree;
55
import com.sun.source.tree.Tree;
6+
import com.sun.tools.javac.code.Symbol;
67
import java.util.Collection;
78
import java.util.Collections;
89
import java.util.Objects;
@@ -91,7 +92,11 @@ public <R, P> R accept(NodeVisitor<R, P> visitor, P p) {
9192

9293
@Override
9394
public String toString() {
94-
return getReceiver() + "." + field;
95+
if (Node.disambiguateOwner) {
96+
return getReceiver() + "." + field + "{owner=" + ((Symbol) element).owner + "}";
97+
} else {
98+
return getReceiver() + "." + field;
99+
}
95100
}
96101

97102
/**

dataflow/src/main/java/org/checkerframework/dataflow/cfg/node/ImplicitThisNode.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ public <R, P> R accept(NodeVisitor<R, P> visitor, P p) {
2626
// used in an inner class context.
2727
@Override
2828
public String toString() {
29-
return "(this)";
29+
if (Node.disambiguateOwner) {
30+
return "(this{owner=" + type + "})";
31+
} else {
32+
return "(this)";
33+
}
3034
}
3135
}

dataflow/src/main/java/org/checkerframework/dataflow/cfg/node/Node.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,12 @@
3535
*/
3636
public abstract class Node implements UniqueId {
3737

38+
/**
39+
* If true, print the owner of each field and {@code this}, to disambiguate shadowing. This field
40+
* is intended for debugging.
41+
*/
42+
public static final boolean disambiguateOwner = false;
43+
3844
/**
3945
* The basic block this node belongs to. If null, this object represents a method formal
4046
* parameter.

dataflow/src/main/java/org/checkerframework/dataflow/cfg/node/SuperNode.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313
* <pre>
1414
* <em>super</em>
1515
* </pre>
16+
*
17+
* Its {@link #type} field is the type of the class in which "super" appears, <em>not</em> the type
18+
* to which the "super" identifier resolves.
1619
*/
1720
public class SuperNode extends Node {
1821

@@ -36,7 +39,11 @@ public <R, P> R accept(NodeVisitor<R, P> visitor, P p) {
3639

3740
@Override
3841
public String toString() {
39-
return "super";
42+
if (Node.disambiguateOwner) {
43+
return "super{owner=" + type + "}";
44+
} else {
45+
return "super";
46+
}
4047
}
4148

4249
@Override

0 commit comments

Comments
 (0)