Skip to content
Open
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import javax.lang.model.element.AnnotationMirror;
import javax.lang.model.element.Element;
import javax.lang.model.element.VariableElement;
import org.checkerframework.checker.mustcall.qual.MustCall;
import org.checkerframework.dataflow.cfg.node.MethodInvocationNode;
import org.checkerframework.dataflow.cfg.visualize.CFGVisualizer;
import org.checkerframework.dataflow.expression.ClassName;
Expand All @@ -28,10 +29,14 @@
* A store that extends {@code CFAbstractStore} and additionally tracks which fields of the 'self'
* reference have been initialized.
*
* @param <V> the type of values in the abstract store
* @param <S> the type of teh abstract store
* @see InitializationTransfer
*/
public class InitializationStore<V extends CFAbstractValue<V>, S extends InitializationStore<V, S>>
extends CFAbstractStore<V, S> {
public class InitializationStore<
V extends CFAbstractValue<@MustCall({}) V>,
S extends InitializationStore<@MustCall({}) V, @MustCall({}) S>>
extends CFAbstractStore<@MustCall({}) V, @MustCall({}) S> {

/** The set of fields that are initialized. */
protected final Set<VariableElement> initializedFields;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import javax.lang.model.type.TypeKind;
import javax.lang.model.type.TypeMirror;
import javax.lang.model.util.ElementFilter;
import org.checkerframework.checker.mustcall.qual.MustCall;
import org.checkerframework.dataflow.analysis.RegularTransferResult;
import org.checkerframework.dataflow.analysis.TransferInput;
import org.checkerframework.dataflow.analysis.TransferResult;
Expand Down Expand Up @@ -56,7 +57,7 @@
public class InitializationTransfer<
V extends CFAbstractValue<V>,
T extends InitializationTransfer<V, T, S>,
S extends InitializationStore<V, S>>
S extends InitializationStore<@MustCall({}) V, @MustCall({}) S>>
extends CFAbstractTransfer<V, S, T> {

protected final InitializationAnnotatedTypeFactory<?, ?, ?, ?> atypeFactory;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ public boolean derivedFromMustCallAlias() {
}

/**
* Gets the must-call type associated with the given resource alias, falling on back on the
* Gets the must-call type associated with the given resource alias, falling back on the
* declared type if there is no refined type for the alias in the store.
*
* @param alias a resource alias
Expand All @@ -366,7 +366,9 @@ private static AnnotationMirror getMustCallValue(
CFValue value = mcStore == null ? null : mcStore.getValue(reference);
if (value != null) {
AnnotationMirror result =
AnnotationUtils.getAnnotationByClass(value.getAnnotations(), MustCall.class);
mcAtf
.getQualifierHierarchy()
.findAnnotationInHierarchy(value.getAnnotations(), mcAtf.TOP);
if (result != null) {
return result;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* Demonstrates an issue in the Checker Framework with handling the nearest enclosing element for
* temporary variable declarations, leading to a crash during analysis.
*/
@SuppressWarnings("all") // only check for crashes
public abstract class CrashForTempVar<T extends Number> {

private final CrashForTempVar<T> _base;
Expand Down
15 changes: 15 additions & 0 deletions checker/tests/resourceleak/DropOwning.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// test case for https://github.com/typetools/checker-framework/issues/6990

import java.io.Closeable;
import org.checkerframework.checker.mustcall.qual.MustCallUnknown;
import org.checkerframework.checker.mustcall.qual.Owning;

public class DropOwning {

public void f(@Owning Closeable resource) {
drop(resource);
}

// :: error: required.method.not.known
private void drop(@Owning @MustCallUnknown Object resourceCF6990) {}
}
Loading