From 45dd8372f8d5aac811ae4b643dcd70ae3a5a916b Mon Sep 17 00:00:00 2001 From: Aosen Xiong Date: Fri, 29 Mar 2024 15:14:02 -0400 Subject: [PATCH 01/17] Adpat to new CF version --- .ci-build-without-test.sh | 8 ++-- scripts/inference-dev | 3 +- .../ExistentialVariableInserter.java | 2 +- .../InferenceAnnotatedTypeFactory.java | 4 +- .../InferenceQualifierHierarchy.java | 39 +++++++++++-------- .../inference/InferenceTypeHierarchy.java | 2 +- src/checkers/inference/InferenceVisitor.java | 15 +++---- src/checkers/inference/VariableAnnotator.java | 21 +++++----- .../inference/dataflow/InferenceTransfer.java | 7 ++-- .../inference/dataflow/InferenceValue.java | 2 +- .../inference/model/ComparableConstraint.java | 4 +- .../inference/model/SubtypeConstraint.java | 2 +- .../inference/solver/frontend/Lattice.java | 2 +- .../solver/frontend/LatticeBuilder.java | 4 +- src/checkers/inference/util/ASTPathUtil.java | 5 ++- .../util/ConstantToVariableAnnotator.java | 2 +- src/checkers/inference/util/JaifBuilder.java | 3 +- .../DataflowAnnotatedTypeFactory.java | 2 +- .../InterningAnnotatedTypeFactory.java | 4 +- .../SimpleFlowAnnotatedTypeFactory.java | 24 ++++++------ .../inference/test/CFInferenceTest.java | 3 +- 21 files changed, 86 insertions(+), 72 deletions(-) diff --git a/.ci-build-without-test.sh b/.ci-build-without-test.sh index 3aa0f97f6..288c81c0d 100755 --- a/.ci-build-without-test.sh +++ b/.ci-build-without-test.sh @@ -24,10 +24,10 @@ export AFU="${AFU:-../annotation-tools/annotation-file-utilities}" AT=$(dirname "${AFU}") ## Build annotation-tools (Annotation File Utilities) -/tmp/plume-scripts/git-clone-related opprop annotation-tools "${AT}" -if [ ! -d ../annotation-tools ] ; then - ln -s "${AT}" ../annotation-tools -fi +#/tmp/plume-scripts/git-clone-related opprop annotation-tools "${AT}" +#if [ ! -d ../annotation-tools ] ; then +# ln -s "${AT}" ../annotation-tools +#fi echo "Running: (cd ${AT} && ./.build-without-test.sh)" (cd "${AT}" && ./.build-without-test.sh) diff --git a/scripts/inference-dev b/scripts/inference-dev index f87e0cd27..3d587e4fe 100755 --- a/scripts/inference-dev +++ b/scripts/inference-dev @@ -34,7 +34,8 @@ libDir="$cfiDir"/lib CFBuild="${cfDir}"/dataflow/"${classes}":"${cfDir}"/javacutil/"${classes}":"${cfDir}"/framework/"${classes}":"${cfDir}"/framework/"${resources}" CFBuild="${CFBuild}":"${cfDir}"/checker/"${classes}":"${cfDir}"/checker/"${resources}":"${annoToolsDir}"/scene-lib/bin -CFDepJars="${stubparserDir}"/javaparser-core/target/stubparser-3.25.2.jar:"${afuDir}"/annotation-file-utilities-all.jar +#CFDepJars="${stubparserDir}"/javaparser-core/target/stubparser-3.25.5.jar:"${afuDir}"/annotation-file-utilities-all.jar +CFDepJars="${afuDir}"/annotation-file-utilities-all.jar # sanity check: ensure each jar in CFDepJars actually exists in the file system # total number of jars diff --git a/src/checkers/inference/ExistentialVariableInserter.java b/src/checkers/inference/ExistentialVariableInserter.java index 0d61038ae..8d293ec53 100644 --- a/src/checkers/inference/ExistentialVariableInserter.java +++ b/src/checkers/inference/ExistentialVariableInserter.java @@ -159,7 +159,7 @@ public void matchAndReplacePrimary(final AnnotatedTypeMirror typeUse, final Anno } @Override - protected String defaultErrorMessage(org.checkerframework.framework.type.AnnotatedTypeMirror type1, org.checkerframework.framework.type.AnnotatedTypeMirror type2, Void aVoid) { + public String defaultErrorMessage(org.checkerframework.framework.type.AnnotatedTypeMirror type1, org.checkerframework.framework.type.AnnotatedTypeMirror type2, Void aVoid) { return "Input types should have identical structures. Input types are limited to those types" + "that can appear in a type variable bound:\n" + "type1=" + type1 + "\n" diff --git a/src/checkers/inference/InferenceAnnotatedTypeFactory.java b/src/checkers/inference/InferenceAnnotatedTypeFactory.java index 879852b71..872c7f4e3 100644 --- a/src/checkers/inference/InferenceAnnotatedTypeFactory.java +++ b/src/checkers/inference/InferenceAnnotatedTypeFactory.java @@ -228,7 +228,7 @@ protected TypeHierarchy createTypeHierarchy() { @Override protected QualifierHierarchy createQualifierHierarchy() { - return new InferenceQualifierHierarchy(getSupportedTypeQualifiers(), elements); + return new InferenceQualifierHierarchy(getSupportedTypeQualifiers(), elements, realTypeFactory); } @Override @@ -352,7 +352,7 @@ public ParameterizedExecutableType methodFromUse(final MethodInvocationTree meth // Adapt parameters, which makes parameters and arguments be the same size for later // checking. List parameters = - AnnotatedTypes.adaptParameters(this, method, methodInvocationTree.getArguments()); + AnnotatedTypes.adaptParameters(this, method, methodInvocationTree.getArguments(), null); method.setParameterTypes(parameters); inferencePoly.replacePolys(methodInvocationTree, method); diff --git a/src/checkers/inference/InferenceQualifierHierarchy.java b/src/checkers/inference/InferenceQualifierHierarchy.java index 67ca38d18..83e500ed7 100644 --- a/src/checkers/inference/InferenceQualifierHierarchy.java +++ b/src/checkers/inference/InferenceQualifierHierarchy.java @@ -9,6 +9,7 @@ import com.google.common.collect.ImmutableMap; import org.checkerframework.checker.nullness.qual.Nullable; import org.checkerframework.framework.type.ElementQualifierHierarchy; +import org.checkerframework.framework.type.GenericAnnotatedTypeFactory; import org.checkerframework.framework.type.QualifierHierarchy; import org.checkerframework.framework.util.DefaultQualifierKindHierarchy; import org.checkerframework.framework.util.QualifierKind; @@ -19,6 +20,7 @@ import org.plumelib.util.StringsPlume; import javax.lang.model.element.AnnotationMirror; +import javax.lang.model.type.TypeMirror; import javax.lang.model.util.Elements; import java.lang.annotation.Annotation; import java.util.Collection; @@ -42,9 +44,10 @@ public class InferenceQualifierHierarchy extends ElementQualifierHierarchy { public InferenceQualifierHierarchy( Collection> qualifierClasses, - Elements elements + Elements elements, + GenericAnnotatedTypeFactory atypeFactory ) { - super(qualifierClasses, elements); + super(qualifierClasses, elements, atypeFactory); slotMgr = inferenceMain.getSlotManager(); constraintMgr = inferenceMain.getConstraintManager(); @@ -137,8 +140,10 @@ public static AnnotationMirror findVarAnnot(final Iterable rhsAnnos, - final Collection lhsAnnos ) { + public boolean isSubtypeShallow(final Collection rhsAnnos, + TypeMirror subType, + final Collection lhsAnnos, + TypeMirror superType ) { final AnnotationMirror rhsVarAnnot = findVarAnnot(rhsAnnos); final AnnotationMirror lhsVarAnnot = findVarAnnot(lhsAnnos); @@ -156,11 +161,11 @@ public boolean isSubtype(final Collection rhsAnnos, + " rhs=" + StringsPlume.join(", ", rhsAnnos) + "\n" + " lhs=" + StringsPlume.join(", ", lhsAnnos ); - return isSubtype(rhsVarAnnot, lhsVarAnnot); + return isSubtypeQualifiers(rhsVarAnnot, lhsVarAnnot); } @Override - public boolean isSubtype(final AnnotationMirror subtype, final AnnotationMirror supertype) { + public boolean isSubtypeQualifiers(final AnnotationMirror subtype, final AnnotationMirror supertype) { // NOTE: subtype and supertype are nullable because, for example, in BaseTypeVisitor::checkConstructorInvocation, // findAnnotationInSameHierarchy may return null since @VarAnnot and some constant real qualifier @@ -187,19 +192,21 @@ public boolean isSubtype(final AnnotationMirror subtype, final AnnotationMirror } @Override - public AnnotationMirror greatestLowerBound(AnnotationMirror a1, AnnotationMirror a2) { + public AnnotationMirror greatestLowerBoundQualifiers(AnnotationMirror a1, AnnotationMirror a2) { return merge(a1, a2, false); } @Override - public Set leastUpperBounds( + public Set leastUpperBoundsShallow( Collection annos1, - Collection annos2) { + TypeMirror tm1, + Collection annos2, + TypeMirror tm2) { if (InferenceMain.isHackMode(annos1.size() != annos2.size())) { Set result = new AnnotationMirrorSet(); for (AnnotationMirror a1 : annos1) { for (AnnotationMirror a2 : annos2) { - AnnotationMirror lub = leastUpperBound(a1, a2); + AnnotationMirror lub = leastUpperBoundQualifiersOnly(a1, a2); if (lub != null) { result.add(lub); } @@ -207,11 +214,11 @@ public Set leastUpperBounds( } return result; } - return super.leastUpperBounds(annos1, annos2); + return super.leastUpperBoundsShallow(annos1, tm1, annos2, tm2); } @Override - public AnnotationMirror leastUpperBound(final AnnotationMirror a1, final AnnotationMirror a2) { + public AnnotationMirror leastUpperBoundQualifiers(final AnnotationMirror a1, final AnnotationMirror a2) { return merge(a1, a2, true); } @@ -239,9 +246,9 @@ private AnnotationMirror merge(final AnnotationMirror a1, final AnnotationMirror if (!isA1VarAnnot && !isA2VarAnnot) { if (isLub) { - return realQualifierHierarchy.leastUpperBound(a1, a2); + return realQualifierHierarchy.leastUpperBoundQualifiersOnly(a1, a2); } else { - return realQualifierHierarchy.greatestLowerBound(a1, a2); + return realQualifierHierarchy.greatestLowerBoundQualifiersOnly(a1, a2); } } else { // two annotations are not under the same qualifier hierarchy @@ -262,9 +269,9 @@ private AnnotationMirror merge(final AnnotationMirror a1, final AnnotationMirror AnnotationMirror mergedType; if (isLub) { - mergedType = realQualifierHierarchy.leastUpperBound(realAnno1, realAnno2); + mergedType = realQualifierHierarchy.leastUpperBoundQualifiersOnly(realAnno1, realAnno2); } else { - mergedType = realQualifierHierarchy.greatestLowerBound(realAnno1, realAnno2); + mergedType = realQualifierHierarchy.greatestLowerBoundQualifiersOnly(realAnno1, realAnno2); } Slot constantSlot = slotMgr.createConstantSlot(mergedType); diff --git a/src/checkers/inference/InferenceTypeHierarchy.java b/src/checkers/inference/InferenceTypeHierarchy.java index 13c93d113..64aa32ab7 100644 --- a/src/checkers/inference/InferenceTypeHierarchy.java +++ b/src/checkers/inference/InferenceTypeHierarchy.java @@ -50,7 +50,7 @@ public boolean areEqual(AnnotatedTypeMirror type1, AnnotatedTypeMirror type2) { public StructuralEqualityComparer createEqualityComparer() { return new InferenceEqualityComparer( this.areEqualVisitHistory, - InferenceQualifierHierarchy.findVarAnnot(qualifierHierarchy.getTopAnnotations())); + InferenceQualifierHierarchy.findVarAnnot(qualHierarchy.getTopAnnotations())); } private static class InferenceEqualityComparer extends StructuralEqualityComparer { diff --git a/src/checkers/inference/InferenceVisitor.java b/src/checkers/inference/InferenceVisitor.java index df07527fa..c24f01c88 100644 --- a/src/checkers/inference/InferenceVisitor.java +++ b/src/checkers/inference/InferenceVisitor.java @@ -489,13 +489,13 @@ protected void checkTypeArguments(Tree toptree, * @param extraArgs arguments to the error message key, before "found" and "expected" types */ @Override - protected void commonAssignmentCheck( + protected boolean commonAssignmentCheck( Tree varTree, ExpressionTree valueExp, @CompilerMessageKey String errorKey, Object... extraArgs) { if (!validateTypeOf(varTree)) { - return; + return true; } AnnotatedTypeMirror var; @@ -516,11 +516,11 @@ protected void commonAssignmentCheck( assert var != null : "no variable found for tree: " + varTree; - commonAssignmentCheck(var, valueExp, errorKey, extraArgs); + return commonAssignmentCheck(var, valueExp, errorKey, extraArgs); } @Override - protected void commonAssignmentCheck( + protected boolean commonAssignmentCheck( AnnotatedTypeMirror varType, AnnotatedTypeMirror valueType, Tree valueTree, @@ -583,7 +583,7 @@ protected void commonAssignmentCheck( mono.getCanonicalName(), mono.getCanonicalName(), valueType.toString()); - return; + return true; } } } @@ -606,6 +606,7 @@ protected void commonAssignmentCheck( errorKey, ArraysPlume.concatenate(extraArgs, valueTypeString, varTypeString)); } + return success; // ####### End Copied Code ######## } @@ -805,7 +806,7 @@ protected void checkExceptionParameter(CatchTree node) { if (exPar.getKind() != TypeKind.UNION) { if (!atypeFactory.getQualifierHierarchy() - .isSubtype(required, found)) { + .isSubtypeQualifiersOnly(required, found)) { checker.reportError(node.getParameter(), "exception.parameter.invalid", found, required); } @@ -814,7 +815,7 @@ protected void checkExceptionParameter(CatchTree node) { for (AnnotatedTypeMirror alterntive : aut.getAlternatives()) { AnnotationMirror foundAltern = alterntive .getAnnotationInHierarchy(required); - if (!atypeFactory.getQualifierHierarchy().isSubtype( + if (!atypeFactory.getQualifierHierarchy().isSubtypeQualifiersOnly( required, foundAltern)) { checker.reportError(node.getParameter(), "exception.parameter.invalid", foundAltern, required); diff --git a/src/checkers/inference/VariableAnnotator.java b/src/checkers/inference/VariableAnnotator.java index 7eea07d65..124e5f9b8 100644 --- a/src/checkers/inference/VariableAnnotator.java +++ b/src/checkers/inference/VariableAnnotator.java @@ -80,6 +80,7 @@ import checkers.inference.util.ASTPathUtil; import checkers.inference.util.CopyUtil; import checkers.inference.util.InferenceUtil; +import org.checkerframework.org.plumelib.util.IPair; /** @@ -108,12 +109,12 @@ public class VariableAnnotator extends AnnotatedTypeScanner { * annotation mirror for a tree is calculated (i.e least upper bound for * binary tree), and the calculated result is cached in the set. **/ - protected final Map>> treeToVarAnnoPair; + protected final Map>> treeToVarAnnoPair; /** Store elements that have already been annotated **/ private final Map elementToAtm; - private final Map, ExistentialVariableSlot> idsToExistentialSlots; + private final Map, ExistentialVariableSlot> idsToExistentialSlots; private final AnnotatedTypeFactory realTypeFactory; private final InferrableChecker realChecker; @@ -238,7 +239,7 @@ private SourceVariableSlot createVariable(final Tree tree) { // } // } - final Pair> varATMPair = Pair + final IPair> varATMPair = IPair .> of(varSlot, new AnnotationMirrorSet()); treeToVarAnnoPair.put(tree, varATMPair); @@ -273,7 +274,7 @@ public ConstantSlot createConstant(final AnnotationMirror value, final Tree tree // } Set annotations = new AnnotationMirrorSet(); annotations.add(constantSlot.getValue()); - final Pair> varATMPair = Pair + final IPair> varATMPair = IPair .> of(constantSlot, annotations); treeToVarAnnoPair.put(tree, varATMPair); @@ -311,7 +312,7 @@ ExistentialVariableSlot getOrCreateExistentialVariable(final AnnotatedTypeMirror */ ExistentialVariableSlot getOrCreateExistentialVariable(final Slot potentialVariable, final Slot alternativeSlot) { - final Pair idPair = Pair.of(potentialVariable.getId(), alternativeSlot.getId()); + final IPair idPair = IPair.of(potentialVariable.getId(), alternativeSlot.getId()); ExistentialVariableSlot existentialVariable = idsToExistentialSlots.get(idPair); if (existentialVariable == null) { @@ -436,7 +437,7 @@ private void addExistentialVariable(final AnnotatedTypeVariable typeVar, final T } potentialVariable = createVariable(typeTree); - final Pair> varATMPair = Pair + final IPair> varATMPair = IPair .> of( potentialVariable, typeVar.getAnnotations()); treeToVarAnnoPair.put(typeTree, varATMPair); @@ -517,7 +518,7 @@ private Slot addPrimaryVariable(AnnotatedTypeMirror atm, final Tree tree) { ((SourceVariableSlot) variable).setInsertable(false); } - final Pair> varATMPair = Pair + final IPair> varATMPair = IPair .of(variable, new AnnotationMirrorSet()); @@ -1542,12 +1543,12 @@ public void handleBinaryTree(AnnotatedTypeMirror atm, BinaryTree binaryTree) { AnnotatedTypeMirror a = inferenceTypeFactory.getAnnotatedType(binaryTree.getLeftOperand()); AnnotatedTypeMirror b = inferenceTypeFactory.getAnnotatedType(binaryTree.getRightOperand()); Set lubs = inferenceTypeFactory - .getQualifierHierarchy().leastUpperBounds(a.getEffectiveAnnotations(), - b.getEffectiveAnnotations()); + .getQualifierHierarchy().leastUpperBoundsShallow(a.getEffectiveAnnotations(), a.getUnderlyingType(), + b.getEffectiveAnnotations(), b.getUnderlyingType()); atm.clearAnnotations(); atm.addAnnotations(lubs); if (slotManager.getSlot(atm) instanceof VariableSlot) { - final Pair> varATMPair = Pair.>of( + final IPair> varATMPair = IPair.>of( slotManager.getSlot(atm), lubs); treeToVarAnnoPair.put(binaryTree, varATMPair); } else { diff --git a/src/checkers/inference/dataflow/InferenceTransfer.java b/src/checkers/inference/dataflow/InferenceTransfer.java index 8ac9dfc19..cd0f494e4 100644 --- a/src/checkers/inference/dataflow/InferenceTransfer.java +++ b/src/checkers/inference/dataflow/InferenceTransfer.java @@ -35,6 +35,7 @@ import checkers.inference.model.Slot; import checkers.inference.model.VariableSlot; import checkers.inference.util.InferenceUtil; +import org.checkerframework.org.plumelib.util.IPair; /** * @@ -58,7 +59,7 @@ public class InferenceTransfer extends CFTransfer { // Type variables will have two refinement variables (one for each bound). This covers the // case where the correct, inferred RHS has no primary annotation - private final Map> createdTypeVarRefinementVariables = new HashMap<>(); + private final Map> createdTypeVarRefinementVariables = new HashMap<>(); private final InferenceAnnotatedTypeFactory typeFactory; @@ -320,7 +321,7 @@ private TransferResult createTypeVarRefinementVars(Node lhs, T final RefinementVariableSlot upperBoundRefVar; final RefinementVariableSlot lowerBoundRefVar; if (createdTypeVarRefinementVariables.containsKey(assignmentTree)) { - Pair ubToLb = createdTypeVarRefinementVariables.get(assignmentTree); + IPair ubToLb = createdTypeVarRefinementVariables.get(assignmentTree); upperBoundRefVar = ubToLb.first; lowerBoundRefVar = ubToLb.second; @@ -337,7 +338,7 @@ private TransferResult createTypeVarRefinementVars(Node lhs, T upperBoundSlot.getRefinedToSlots().add(upperBoundRefVar); lowerBoundSlot.getRefinedToSlots().add(lowerBoundRefVar); - createdTypeVarRefinementVariables.put(assignmentTree, Pair.of(upperBoundRefVar, lowerBoundRefVar)); + createdTypeVarRefinementVariables.put(assignmentTree, IPair.of(upperBoundRefVar, lowerBoundRefVar)); } upperBoundType.replaceAnnotation(slotManager.getAnnotation(upperBoundRefVar)); diff --git a/src/checkers/inference/dataflow/InferenceValue.java b/src/checkers/inference/dataflow/InferenceValue.java index b729a6b97..e593cbc53 100644 --- a/src/checkers/inference/dataflow/InferenceValue.java +++ b/src/checkers/inference/dataflow/InferenceValue.java @@ -68,7 +68,7 @@ public CFValue leastUpperBound(CFValue other) { // Delegate the LUB computation to inferenceQualifierHierarchy, by passing // the two VarAnnos getting from slotManager. - final AnnotationMirror lub = qualifierHierarchy.leastUpperBound(anno1, anno2); + final AnnotationMirror lub = qualifierHierarchy.leastUpperBoundQualifiersOnly(anno1, anno2); return analysis.createAbstractValue(AnnotationMirrorSet.singleton(lub), getLubType(other, null)); } diff --git a/src/checkers/inference/model/ComparableConstraint.java b/src/checkers/inference/model/ComparableConstraint.java index 443d2f3cc..0c58e32f1 100644 --- a/src/checkers/inference/model/ComparableConstraint.java +++ b/src/checkers/inference/model/ComparableConstraint.java @@ -44,8 +44,8 @@ protected static Constraint create(Slot first, Slot second, AnnotationLocation l ConstantSlot firstConst = (ConstantSlot) first; ConstantSlot secondConst = (ConstantSlot) second; - return realQualHierarchy.isSubtype(firstConst.getValue(), secondConst.getValue()) - || realQualHierarchy.isSubtype(secondConst.getValue(), firstConst.getValue()) + return realQualHierarchy.isSubtypeQualifiersOnly(firstConst.getValue(), secondConst.getValue()) + || realQualHierarchy.isSubtypeQualifiersOnly(secondConst.getValue(), firstConst.getValue()) ? AlwaysTrueConstraint.create() : AlwaysFalseConstraint.create(); } diff --git a/src/checkers/inference/model/SubtypeConstraint.java b/src/checkers/inference/model/SubtypeConstraint.java index 9b26a193d..b2f787372 100644 --- a/src/checkers/inference/model/SubtypeConstraint.java +++ b/src/checkers/inference/model/SubtypeConstraint.java @@ -66,7 +66,7 @@ protected static Constraint create(Slot subtype, Slot supertype, AnnotationLocat ConstantSlot subConstant = (ConstantSlot) subtype; ConstantSlot superConstant = (ConstantSlot) supertype; - return realQualHierarchy.isSubtype(subConstant.getValue(), superConstant.getValue()) + return realQualHierarchy.isSubtypeQualifiersOnly(subConstant.getValue(), superConstant.getValue()) ? AlwaysTrueConstraint.create() : AlwaysFalseConstraint.create(); } diff --git a/src/checkers/inference/solver/frontend/Lattice.java b/src/checkers/inference/solver/frontend/Lattice.java index d46b8c0b1..89b2a0fb7 100644 --- a/src/checkers/inference/solver/frontend/Lattice.java +++ b/src/checkers/inference/solver/frontend/Lattice.java @@ -90,7 +90,7 @@ public Lattice(Map> subType, } public boolean isSubtype(AnnotationMirror a1, AnnotationMirror a2) { - return underlyingQualifierHierarchy.isSubtype(a1, a2); + return underlyingQualifierHierarchy.isSubtypeQualifiersOnly(a1, a2); } } diff --git a/src/checkers/inference/solver/frontend/LatticeBuilder.java b/src/checkers/inference/solver/frontend/LatticeBuilder.java index b386a81d6..e0b85bd25 100644 --- a/src/checkers/inference/solver/frontend/LatticeBuilder.java +++ b/src/checkers/inference/solver/frontend/LatticeBuilder.java @@ -108,10 +108,10 @@ public Lattice buildLattice(QualifierHierarchy qualHierarchy, Collection s Set subtypeOfi = new HashSet(); Set supertypeOfi = new HashSet(); for (AnnotationMirror j : allTypes) { - if (qualHierarchy.isSubtype(j, i)) { + if (qualHierarchy.isSubtypeQualifiersOnly(j, i)) { subtypeOfi.add(j); } - if (qualHierarchy.isSubtype(i, j)) { + if (qualHierarchy.isSubtypeQualifiersOnly(i, j)) { supertypeOfi.add(j); } } diff --git a/src/checkers/inference/util/ASTPathUtil.java b/src/checkers/inference/util/ASTPathUtil.java index a825598ad..4e9d72c38 100644 --- a/src/checkers/inference/util/ASTPathUtil.java +++ b/src/checkers/inference/util/ASTPathUtil.java @@ -27,6 +27,7 @@ import org.checkerframework.afu.scenelib.io.ASTIndex; import org.checkerframework.afu.scenelib.io.ASTPath; import org.checkerframework.afu.scenelib.io.ASTRecord; +import org.checkerframework.org.plumelib.util.IPair; /** * ASTPathUtil is a collection of utilities to create ASTRecord for existing trees, as well @@ -230,7 +231,7 @@ public Void visitWildcard(AnnotatedWildcardType type, ASTRecord current) { /** * Converts fully qualified class name into a pair of Strings (packageName -> className) */ - public static Pair splitFullyQualifiedClass(String fullClassname) { + public static IPair splitFullyQualifiedClass(String fullClassname) { String pkgName; String className; int lastPeriod = fullClassname.lastIndexOf("."); @@ -243,6 +244,6 @@ public static Pair splitFullyQualifiedClass(String fullClassname className = fullClassname.substring(lastPeriod + 1, fullClassname.length()); } - return Pair.of(pkgName, className); + return IPair.of(pkgName, className); } } diff --git a/src/checkers/inference/util/ConstantToVariableAnnotator.java b/src/checkers/inference/util/ConstantToVariableAnnotator.java index 892ea765f..23ebb982c 100644 --- a/src/checkers/inference/util/ConstantToVariableAnnotator.java +++ b/src/checkers/inference/util/ConstantToVariableAnnotator.java @@ -43,7 +43,7 @@ protected Void scan(AnnotatedTypeMirror type, Void aVoid) { * @param type A type annotated in the "real qualifier hierarch" */ protected void addVariablePrimaryAnnotation(final AnnotatedTypeMirror type) { - if (type.isAnnotatedInHierarchy(varAnnot)) { + if (type.hasAnnotationInHierarchy(varAnnot)) { return; } diff --git a/src/checkers/inference/util/JaifBuilder.java b/src/checkers/inference/util/JaifBuilder.java index 03bf0b0f8..9ae245ffa 100644 --- a/src/checkers/inference/util/JaifBuilder.java +++ b/src/checkers/inference/util/JaifBuilder.java @@ -23,6 +23,7 @@ import com.sun.source.tree.Tree; import org.checkerframework.javacutil.Pair; +import org.checkerframework.org.plumelib.util.IPair; /** * JaifBuilder creates Jaifs from a Map of ASTRecords to AnnotationMirrors. @@ -416,7 +417,7 @@ private ClassEntry getClassEntry(ClassDeclLocation location) { private ClassEntry getClassEntry(String fullyQualified) { ClassEntry classEntry = this.classesMap.get(fullyQualified); if (classEntry == null) { - Pair packageToClass = ASTPathUtil.splitFullyQualifiedClass(fullyQualified); + IPair packageToClass = ASTPathUtil.splitFullyQualifiedClass(fullyQualified); classEntry = new ClassEntry(packageToClass.first, packageToClass.second); this.classesMap.put(fullyQualified, classEntry); } diff --git a/src/dataflow/DataflowAnnotatedTypeFactory.java b/src/dataflow/DataflowAnnotatedTypeFactory.java index f2aad8a10..56bda64a1 100644 --- a/src/dataflow/DataflowAnnotatedTypeFactory.java +++ b/src/dataflow/DataflowAnnotatedTypeFactory.java @@ -126,7 +126,7 @@ public DataFlowQualifierHierarchy( Collection> qualifierClasses, Elements elements ) { - super(qualifierClasses, elements); + super(qualifierClasses, elements, DataflowAnnotatedTypeFactory.this); DATAFLOW_KIND = getQualifierKind(DATAFLOW); } diff --git a/src/interning/InterningAnnotatedTypeFactory.java b/src/interning/InterningAnnotatedTypeFactory.java index 141efa41b..37dbff13f 100644 --- a/src/interning/InterningAnnotatedTypeFactory.java +++ b/src/interning/InterningAnnotatedTypeFactory.java @@ -90,7 +90,7 @@ protected TypeAnnotator createTypeAnnotator() { @Override public void addComputedTypeAnnotations(Element element, AnnotatedTypeMirror type) { - if (!type.isAnnotatedInHierarchy(INTERNED) && ElementUtils.isCompileTimeConstant(element)) + if (!type.hasAnnotationInHierarchy(INTERNED) && ElementUtils.isCompileTimeConstant(element)) type.addAnnotation(INTERNED); super.addComputedTypeAnnotations(element, type); } @@ -153,7 +153,7 @@ public Void visitDeclared(AnnotatedDeclaredType t, Void p) { // TODO: @Interned then the type would already receive an @Interned from the framework without // TODO: this case (I think from InheritFromClass) // TODO: IF this is true, perhaps remove item 6 I added to the class comment - } else if (typeFactory.fromElement(elt).hasAnnotation(INTERNED)) { + } else if (atypeFactory.fromElement(elt).hasAnnotation(INTERNED)) { // If the class/interface has an @Interned annotation, use it. t.replaceAnnotation(INTERNED); } diff --git a/src/sparta/checkers/SimpleFlowAnnotatedTypeFactory.java b/src/sparta/checkers/SimpleFlowAnnotatedTypeFactory.java index 442318701..07bcc2c4a 100644 --- a/src/sparta/checkers/SimpleFlowAnnotatedTypeFactory.java +++ b/src/sparta/checkers/SimpleFlowAnnotatedTypeFactory.java @@ -300,12 +300,12 @@ public FlowQualifierHierarchy( Collection> qualifierClasses, Elements elements ) { - super(qualifierClasses, elements); + super(qualifierClasses, elements, SimpleFlowAnnotatedTypeFactory.this); } @Override - public Set getTopAnnotations() { - return Collections.singleton(checker instanceof IFlowSinkChecker ? + public AnnotationMirrorSet getTopAnnotations() { + return AnnotationMirrorSet.singleton(checker instanceof IFlowSinkChecker ? NOSINK : ANYSOURCE); } @@ -320,8 +320,8 @@ public AnnotationMirror getTopAnnotation(AnnotationMirror start) { } @Override - public Set getBottomAnnotations() { - return Collections.singleton(checker instanceof IFlowSinkChecker ? + public AnnotationMirrorSet getBottomAnnotations() { + return AnnotationMirrorSet.singleton(checker instanceof IFlowSinkChecker ? ANYSINK : NOSOURCE); } @@ -336,12 +336,12 @@ public AnnotationMirror getBottomAnnotation(AnnotationMirror start) { } @Override - public @Nullable AnnotationMirror leastUpperBound(AnnotationMirror a1, AnnotationMirror a2) { + public @Nullable AnnotationMirror leastUpperBoundQualifiers(AnnotationMirror a1, AnnotationMirror a2) { if (!AnnotationUtils.areSameByName(getTopAnnotation(a1), getTopAnnotation(a2))) { return null; - } else if (isSubtype(a1, a2)) { + } else if (isSubtypeQualifiersOnly(a1, a2)) { return a2; - } else if (isSubtype(a2, a1)) { + } else if (isSubtypeQualifiersOnly(a2, a1)) { return a1; } else if (isSourceQualifier(a1)) { // Since the two annotations are same by name, they are both source qualifier. @@ -359,12 +359,12 @@ public AnnotationMirror getBottomAnnotation(AnnotationMirror start) { } @Override - public @Nullable AnnotationMirror greatestLowerBound(AnnotationMirror a1, AnnotationMirror a2) { + public @Nullable AnnotationMirror greatestLowerBoundQualifiers(AnnotationMirror a1, AnnotationMirror a2) { if (!AnnotationUtils.areSameByName(getTopAnnotation(a1), getTopAnnotation(a2))) { return null; - } else if (isSubtype(a1, a2)) { + } else if (isSubtypeQualifiersOnly(a1, a2)) { return a1; - } else if (isSubtype(a2, a1)) { + } else if (isSubtypeQualifiersOnly(a2, a1)) { return a2; } else if (isSourceQualifier(a1)) { // Since the two annotations are same by name, they are both source qualifier. @@ -382,7 +382,7 @@ public AnnotationMirror getBottomAnnotation(AnnotationMirror start) { } @Override - public boolean isSubtype(AnnotationMirror subtype, AnnotationMirror supertype) { + public boolean isSubtypeQualifiers(AnnotationMirror subtype, AnnotationMirror supertype) { if (isPolySourceQualifier(supertype) && isPolySourceQualifier(subtype)) { return true; } else if (isPolySourceQualifier(supertype) && isSourceQualifier(subtype)) { diff --git a/tests/checkers/inference/test/CFInferenceTest.java b/tests/checkers/inference/test/CFInferenceTest.java index b2ee3f9df..3b11706e1 100644 --- a/tests/checkers/inference/test/CFInferenceTest.java +++ b/tests/checkers/inference/test/CFInferenceTest.java @@ -11,6 +11,7 @@ import javax.annotation.processing.AbstractProcessor; +import org.checkerframework.org.plumelib.util.SystemPlume; import org.junit.Test; public abstract class CFInferenceTest extends CheckerFrameworkPerFileTest { @@ -27,7 +28,7 @@ public CFInferenceTest(File testFile, Class checker } public boolean useHacks() { - return SystemUtil.getBooleanSystemProperty("use.hacks"); + return SystemPlume.getBooleanSystemProperty("use.hacks"); } public abstract Pair> getSolverNameAndOptions(); From 13f832c7d66dbe2e2273a60d3c62babfbce03e33 Mon Sep 17 00:00:00 2001 From: Aosen Xiong Date: Fri, 29 Mar 2024 15:18:42 -0400 Subject: [PATCH 02/17] Clone and build annotation-tool in opprop --- .ci-build-without-test.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.ci-build-without-test.sh b/.ci-build-without-test.sh index 288c81c0d..c97363151 100755 --- a/.ci-build-without-test.sh +++ b/.ci-build-without-test.sh @@ -23,11 +23,11 @@ export AFU="${AFU:-../annotation-tools/annotation-file-utilities}" # Don't use `AT=${AFU}/..` which causes a git failure. AT=$(dirname "${AFU}") -## Build annotation-tools (Annotation File Utilities) -#/tmp/plume-scripts/git-clone-related opprop annotation-tools "${AT}" -#if [ ! -d ../annotation-tools ] ; then -# ln -s "${AT}" ../annotation-tools -#fi +# Build annotation-tools (Annotation File Utilities) +/tmp/plume-scripts/git-clone-related opprop annotation-tools "${AT}" +if [ ! -d ../annotation-tools ] ; then + ln -s "${AT}" ../annotation-tools +fi echo "Running: (cd ${AT} && ./.build-without-test.sh)" (cd "${AT}" && ./.build-without-test.sh) From eb9a391a2abf8b315e2854488c65609d043d381a Mon Sep 17 00:00:00 2001 From: Aosen Xiong Date: Fri, 29 Mar 2024 15:36:41 -0400 Subject: [PATCH 03/17] Use Ipair instead of Pair in all files --- src/checkers/inference/BaseInferrableChecker.java | 3 --- src/checkers/inference/InferenceAnnotatedTypeFactory.java | 8 -------- src/checkers/inference/InferrableChecker.java | 3 --- src/checkers/inference/VariableAnnotator.java | 2 -- src/checkers/inference/dataflow/InferenceAnalysis.java | 5 ----- src/checkers/inference/dataflow/InferenceTransfer.java | 1 - src/checkers/inference/util/ASTPathUtil.java | 1 - src/checkers/inference/util/JaifBuilder.java | 1 - tests/checkers/inference/DataflowInferenceTest.java | 6 +++--- tests/checkers/inference/IFlowSinkPropTest.java | 6 +++--- tests/checkers/inference/IFlowSinkSatTest.java | 6 +++--- tests/checkers/inference/IFlowSourcePropTest.java | 6 +++--- tests/checkers/inference/IFlowSourceSatTest.java | 6 +++--- tests/checkers/inference/InterningTest.java | 6 +++--- tests/checkers/inference/NninfTest.java | 6 +++--- tests/checkers/inference/OsTrustedTest.java | 6 +++--- tests/checkers/inference/test/CFInferenceTest.java | 6 +++--- 17 files changed, 27 insertions(+), 51 deletions(-) diff --git a/src/checkers/inference/BaseInferrableChecker.java b/src/checkers/inference/BaseInferrableChecker.java index b10a8cbe9..96e0c078f 100644 --- a/src/checkers/inference/BaseInferrableChecker.java +++ b/src/checkers/inference/BaseInferrableChecker.java @@ -6,12 +6,9 @@ import org.checkerframework.framework.flow.CFTransfer; import org.checkerframework.framework.flow.CFValue; import org.checkerframework.framework.type.GenericAnnotatedTypeFactory; -import org.checkerframework.javacutil.Pair; import java.lang.annotation.Annotation; import java.util.Collections; -import java.util.List; import java.util.Set; -import javax.lang.model.element.VariableElement; import checkers.inference.dataflow.InferenceAnalysis; import checkers.inference.dataflow.InferenceTransfer; diff --git a/src/checkers/inference/InferenceAnnotatedTypeFactory.java b/src/checkers/inference/InferenceAnnotatedTypeFactory.java index 872c7f4e3..a949467b2 100644 --- a/src/checkers/inference/InferenceAnnotatedTypeFactory.java +++ b/src/checkers/inference/InferenceAnnotatedTypeFactory.java @@ -1,8 +1,6 @@ package checkers.inference; -import checkers.inference.model.ConstantSlot; import checkers.inference.model.Slot; -import com.sun.source.util.TreePath; import org.checkerframework.common.basetype.BaseAnnotatedTypeFactory; import org.checkerframework.framework.flow.CFAbstractAnalysis; import org.checkerframework.framework.flow.CFAnalysis; @@ -25,18 +23,14 @@ import org.checkerframework.framework.type.visitor.AnnotatedTypeScanner; import org.checkerframework.framework.util.AnnotatedTypes; import org.checkerframework.framework.util.defaults.QualifierDefaults; -import org.checkerframework.framework.util.dependenttypes.DependentTypesHelper; import org.checkerframework.javacutil.AnnotationBuilder; import org.checkerframework.javacutil.AnnotationMirrorSet; import org.checkerframework.javacutil.BugInCF; import org.checkerframework.javacutil.ElementUtils; -import org.checkerframework.javacutil.Pair; import org.checkerframework.javacutil.TreeUtils; import java.lang.annotation.Annotation; import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; import java.util.HashSet; import java.util.LinkedList; import java.util.List; @@ -49,14 +43,12 @@ import javax.lang.model.element.ExecutableElement; import javax.lang.model.element.TypeElement; import javax.lang.model.element.TypeParameterElement; -import javax.lang.model.element.VariableElement; import javax.lang.model.type.TypeKind; import javax.lang.model.type.TypeMirror; import javax.lang.model.type.TypeVariable; import checkers.inference.dataflow.InferenceAnalysis; import checkers.inference.model.ConstraintManager; -import checkers.inference.model.Slot; import checkers.inference.qual.VarAnnot; import checkers.inference.util.ConstantToVariableAnnotator; import checkers.inference.util.InferenceUtil; diff --git a/src/checkers/inference/InferrableChecker.java b/src/checkers/inference/InferrableChecker.java index 3e63e4bbf..c5f99e6fc 100644 --- a/src/checkers/inference/InferrableChecker.java +++ b/src/checkers/inference/InferrableChecker.java @@ -6,12 +6,9 @@ import org.checkerframework.framework.flow.CFTransfer; import org.checkerframework.framework.flow.CFValue; import org.checkerframework.framework.type.GenericAnnotatedTypeFactory; -import org.checkerframework.javacutil.Pair; import java.lang.annotation.Annotation; -import java.util.List; import java.util.Set; import javax.annotation.processing.ProcessingEnvironment; -import javax.lang.model.element.VariableElement; import checkers.inference.dataflow.InferenceAnalysis; import checkers.inference.model.ConstraintManager; diff --git a/src/checkers/inference/VariableAnnotator.java b/src/checkers/inference/VariableAnnotator.java index 124e5f9b8..f04e9c8df 100644 --- a/src/checkers/inference/VariableAnnotator.java +++ b/src/checkers/inference/VariableAnnotator.java @@ -14,10 +14,8 @@ import org.checkerframework.framework.type.visitor.AnnotatedTypeScanner; import org.checkerframework.javacutil.AnnotationBuilder; import org.checkerframework.javacutil.AnnotationMirrorSet; -import org.checkerframework.javacutil.AnnotationUtils; import org.checkerframework.javacutil.ElementUtils; import org.checkerframework.javacutil.BugInCF; -import org.checkerframework.javacutil.Pair; import org.checkerframework.javacutil.TreePathUtil; import org.checkerframework.javacutil.TreeUtils; import org.checkerframework.javacutil.TypesUtils; diff --git a/src/checkers/inference/dataflow/InferenceAnalysis.java b/src/checkers/inference/dataflow/InferenceAnalysis.java index eb0d02f3f..6f8aa2811 100644 --- a/src/checkers/inference/dataflow/InferenceAnalysis.java +++ b/src/checkers/inference/dataflow/InferenceAnalysis.java @@ -1,11 +1,7 @@ package checkers.inference.dataflow; -import java.util.List; -import java.util.Set; import java.util.logging.Logger; -import javax.lang.model.element.AnnotationMirror; -import javax.lang.model.element.VariableElement; import javax.lang.model.type.TypeKind; import javax.lang.model.type.TypeMirror; @@ -17,7 +13,6 @@ import org.checkerframework.framework.type.GenericAnnotatedTypeFactory; import org.checkerframework.javacutil.AnnotationMirrorSet; import org.checkerframework.javacutil.BugInCF; -import org.checkerframework.javacutil.Pair; import checkers.inference.InferenceChecker; import checkers.inference.InferrableChecker; diff --git a/src/checkers/inference/dataflow/InferenceTransfer.java b/src/checkers/inference/dataflow/InferenceTransfer.java index cd0f494e4..5e3e73302 100644 --- a/src/checkers/inference/dataflow/InferenceTransfer.java +++ b/src/checkers/inference/dataflow/InferenceTransfer.java @@ -14,7 +14,6 @@ import org.checkerframework.framework.type.AnnotatedTypeMirror; import org.checkerframework.framework.type.AnnotatedTypeMirror.AnnotatedTypeVariable; import org.checkerframework.javacutil.BugInCF; -import org.checkerframework.javacutil.Pair; import java.util.HashMap; import java.util.Map; diff --git a/src/checkers/inference/util/ASTPathUtil.java b/src/checkers/inference/util/ASTPathUtil.java index 4e9d72c38..156562572 100644 --- a/src/checkers/inference/util/ASTPathUtil.java +++ b/src/checkers/inference/util/ASTPathUtil.java @@ -15,7 +15,6 @@ import org.checkerframework.framework.type.visitor.AnnotatedTypeScanner; import org.checkerframework.framework.util.AnnotatedTypes; import org.checkerframework.javacutil.BugInCF; -import org.checkerframework.javacutil.Pair; import java.util.IdentityHashMap; import java.util.logging.Logger; diff --git a/src/checkers/inference/util/JaifBuilder.java b/src/checkers/inference/util/JaifBuilder.java index 9ae245ffa..014e8df8f 100644 --- a/src/checkers/inference/util/JaifBuilder.java +++ b/src/checkers/inference/util/JaifBuilder.java @@ -22,7 +22,6 @@ import com.sun.source.tree.Tree; -import org.checkerframework.javacutil.Pair; import org.checkerframework.org.plumelib.util.IPair; /** diff --git a/tests/checkers/inference/DataflowInferenceTest.java b/tests/checkers/inference/DataflowInferenceTest.java index bb530736f..46b6047ae 100644 --- a/tests/checkers/inference/DataflowInferenceTest.java +++ b/tests/checkers/inference/DataflowInferenceTest.java @@ -5,7 +5,7 @@ import java.util.List; import org.checkerframework.framework.test.TestUtilities; -import org.checkerframework.javacutil.Pair; +import org.checkerframework.org.plumelib.util.IPair; import org.junit.runners.Parameterized.Parameters; import checkers.inference.test.CFInferenceTest; @@ -19,8 +19,8 @@ public DataflowInferenceTest(File testFile) { } @Override - public Pair> getSolverNameAndOptions() { - return Pair.> of(DataflowSolverEngine.class.getCanonicalName(), + public IPair> getSolverNameAndOptions() { + return IPair.> of(DataflowSolverEngine.class.getCanonicalName(), new ArrayList()); } diff --git a/tests/checkers/inference/IFlowSinkPropTest.java b/tests/checkers/inference/IFlowSinkPropTest.java index 3e65986ec..7f3745328 100644 --- a/tests/checkers/inference/IFlowSinkPropTest.java +++ b/tests/checkers/inference/IFlowSinkPropTest.java @@ -2,7 +2,7 @@ import checkers.inference.test.CFInferenceTest; import org.checkerframework.framework.test.TestUtilities; -import org.checkerframework.javacutil.Pair; +import org.checkerframework.org.plumelib.util.IPair; import org.junit.runners.Parameterized.Parameters; import sparta.checkers.IFlowSinkChecker; import sparta.checkers.propagation.IFlowSinkSolver; @@ -19,8 +19,8 @@ public IFlowSinkPropTest(File testFile) { } @Override - public Pair> getSolverNameAndOptions() { - return Pair.>of(IFlowSinkSolver.class.getCanonicalName(), new ArrayList()); + public IPair> getSolverNameAndOptions() { + return IPair.>of(IFlowSinkSolver.class.getCanonicalName(), new ArrayList()); } @Parameters diff --git a/tests/checkers/inference/IFlowSinkSatTest.java b/tests/checkers/inference/IFlowSinkSatTest.java index 2f3fd92af..7e6d45707 100644 --- a/tests/checkers/inference/IFlowSinkSatTest.java +++ b/tests/checkers/inference/IFlowSinkSatTest.java @@ -2,7 +2,7 @@ import checkers.inference.test.CFInferenceTest; import org.checkerframework.framework.test.TestUtilities; -import org.checkerframework.javacutil.Pair; +import org.checkerframework.org.plumelib.util.IPair; import org.junit.runners.Parameterized.Parameters; import sparta.checkers.IFlowSinkChecker; import sparta.checkers.sat.SinkSolver; @@ -19,8 +19,8 @@ public IFlowSinkSatTest(File testFile) { } @Override - public Pair> getSolverNameAndOptions() { - return Pair.>of(SinkSolver.class.getCanonicalName(), new ArrayList()); + public IPair> getSolverNameAndOptions() { + return IPair.>of(SinkSolver.class.getCanonicalName(), new ArrayList()); } @Parameters diff --git a/tests/checkers/inference/IFlowSourcePropTest.java b/tests/checkers/inference/IFlowSourcePropTest.java index b616b2824..e83b5541c 100644 --- a/tests/checkers/inference/IFlowSourcePropTest.java +++ b/tests/checkers/inference/IFlowSourcePropTest.java @@ -2,7 +2,7 @@ import checkers.inference.test.CFInferenceTest; import org.checkerframework.framework.test.TestUtilities; -import org.checkerframework.javacutil.Pair; +import org.checkerframework.org.plumelib.util.IPair; import org.junit.runners.Parameterized.Parameters; import sparta.checkers.IFlowSourceChecker; import sparta.checkers.propagation.IFlowSourceSolver; @@ -19,8 +19,8 @@ public IFlowSourcePropTest(File testFile) { } @Override - public Pair> getSolverNameAndOptions() { - return Pair.>of(IFlowSourceSolver.class.getCanonicalName(), new ArrayList()); + public IPair> getSolverNameAndOptions() { + return IPair.>of(IFlowSourceSolver.class.getCanonicalName(), new ArrayList()); } @Parameters diff --git a/tests/checkers/inference/IFlowSourceSatTest.java b/tests/checkers/inference/IFlowSourceSatTest.java index eae20a3fb..b3a43f197 100644 --- a/tests/checkers/inference/IFlowSourceSatTest.java +++ b/tests/checkers/inference/IFlowSourceSatTest.java @@ -2,7 +2,7 @@ import checkers.inference.test.CFInferenceTest; import org.checkerframework.framework.test.TestUtilities; -import org.checkerframework.javacutil.Pair; +import org.checkerframework.org.plumelib.util.IPair; import org.junit.runners.Parameterized.Parameters; import sparta.checkers.IFlowSourceChecker; import sparta.checkers.sat.SourceSolver; @@ -19,8 +19,8 @@ public IFlowSourceSatTest(File testFile) { } @Override - public Pair> getSolverNameAndOptions() { - return Pair.>of(SourceSolver.class.getCanonicalName(), new ArrayList()); + public IPair> getSolverNameAndOptions() { + return IPair.>of(SourceSolver.class.getCanonicalName(), new ArrayList()); } @Parameters diff --git a/tests/checkers/inference/InterningTest.java b/tests/checkers/inference/InterningTest.java index 17896d37e..df0a3f160 100644 --- a/tests/checkers/inference/InterningTest.java +++ b/tests/checkers/inference/InterningTest.java @@ -3,7 +3,7 @@ import checkers.inference.solver.MaxSat2TypeSolver; import checkers.inference.test.CFInferenceTest; import org.checkerframework.framework.test.TestUtilities; -import org.checkerframework.javacutil.Pair; +import org.checkerframework.org.plumelib.util.IPair; import org.junit.runners.Parameterized.Parameters; import java.io.File; @@ -18,8 +18,8 @@ public InterningTest(File testFile) { } @Override - public Pair> getSolverNameAndOptions() { - return Pair.>of(MaxSat2TypeSolver.class.getCanonicalName(), new ArrayList()); + public IPair> getSolverNameAndOptions() { + return IPair.>of(MaxSat2TypeSolver.class.getCanonicalName(), new ArrayList()); } @Parameters diff --git a/tests/checkers/inference/NninfTest.java b/tests/checkers/inference/NninfTest.java index 5522609a6..1205afc78 100644 --- a/tests/checkers/inference/NninfTest.java +++ b/tests/checkers/inference/NninfTest.java @@ -3,7 +3,7 @@ import checkers.inference.solver.MaxSat2TypeSolver; import checkers.inference.test.CFInferenceTest; import org.checkerframework.framework.test.TestUtilities; -import org.checkerframework.javacutil.Pair; +import org.checkerframework.org.plumelib.util.IPair; import org.junit.runners.Parameterized.Parameters; import java.io.File; @@ -18,8 +18,8 @@ public NninfTest(File testFile) { } @Override - public Pair> getSolverNameAndOptions() { - return Pair.of(MaxSat2TypeSolver.class.getCanonicalName(), new ArrayList<>()); + public IPair> getSolverNameAndOptions() { + return IPair.of(MaxSat2TypeSolver.class.getCanonicalName(), new ArrayList<>()); } @Parameters diff --git a/tests/checkers/inference/OsTrustedTest.java b/tests/checkers/inference/OsTrustedTest.java index 5551acaed..cd8580a0f 100644 --- a/tests/checkers/inference/OsTrustedTest.java +++ b/tests/checkers/inference/OsTrustedTest.java @@ -3,7 +3,7 @@ import checkers.inference.solver.MaxSat2TypeSolver; import checkers.inference.test.CFInferenceTest; import org.checkerframework.framework.test.TestUtilities; -import org.checkerframework.javacutil.Pair; +import org.checkerframework.org.plumelib.util.IPair; import org.junit.runners.Parameterized.Parameters; import java.io.File; @@ -18,8 +18,8 @@ public OsTrustedTest(File testFile) { } @Override - public Pair> getSolverNameAndOptions() { - return Pair.>of(MaxSat2TypeSolver.class.getCanonicalName(), new ArrayList()); + public IPair> getSolverNameAndOptions() { + return IPair.>of(MaxSat2TypeSolver.class.getCanonicalName(), new ArrayList()); } @Parameters diff --git a/tests/checkers/inference/test/CFInferenceTest.java b/tests/checkers/inference/test/CFInferenceTest.java index 3b11706e1..e27896c8c 100644 --- a/tests/checkers/inference/test/CFInferenceTest.java +++ b/tests/checkers/inference/test/CFInferenceTest.java @@ -2,7 +2,6 @@ import org.checkerframework.framework.test.CheckerFrameworkPerFileTest; import org.checkerframework.framework.test.TestUtilities; -import org.checkerframework.javacutil.Pair; import org.checkerframework.javacutil.SystemUtil; import java.io.File; @@ -11,6 +10,7 @@ import javax.annotation.processing.AbstractProcessor; +import org.checkerframework.org.plumelib.util.IPair; import org.checkerframework.org.plumelib.util.SystemPlume; import org.junit.Test; @@ -31,7 +31,7 @@ public boolean useHacks() { return SystemPlume.getBooleanSystemProperty("use.hacks"); } - public abstract Pair> getSolverNameAndOptions(); + public abstract IPair> getSolverNameAndOptions(); public List getAdditionalInferenceOptions() { return new ArrayList(); @@ -49,7 +49,7 @@ public String getPathToInferenceScript() { @Test public void run() { boolean shouldEmitDebugInfo = TestUtilities.getShouldEmitDebugInfo(); - Pair> solverArgs = getSolverNameAndOptions(); + IPair> solverArgs = getSolverNameAndOptions(); final File testDataDir = new File("testdata"); From d0a03c972fc5a6b1eccbc2431e19767347bfd677 Mon Sep 17 00:00:00 2001 From: Haifeng Shi Date: Wed, 21 Dec 2022 11:02:04 -0500 Subject: [PATCH 04/17] corresponding changes in CFI about enforce-targetlocations --- .../inference/InferenceValidator.java | 27 ++++++ src/checkers/inference/InferenceVisitor.java | 97 ++++++++++++++++++- 2 files changed, 123 insertions(+), 1 deletion(-) diff --git a/src/checkers/inference/InferenceValidator.java b/src/checkers/inference/InferenceValidator.java index bb7988455..9177af611 100644 --- a/src/checkers/inference/InferenceValidator.java +++ b/src/checkers/inference/InferenceValidator.java @@ -1,9 +1,16 @@ package checkers.inference; +import com.sun.source.tree.Tree; import org.checkerframework.common.basetype.BaseTypeChecker; import org.checkerframework.common.basetype.BaseTypeValidator; +import org.checkerframework.framework.qual.TypeUseLocation; import org.checkerframework.framework.type.AnnotatedTypeFactory; +import org.checkerframework.framework.type.AnnotatedTypeMirror; +import org.checkerframework.javacutil.AnnotationUtils; + +import javax.lang.model.element.AnnotationMirror; +import java.util.List; /** * A visitor to validate the types in a tree. @@ -29,4 +36,24 @@ public InferenceValidator(BaseTypeChecker checker, public void setInfer(boolean infer) { this.infer = infer; } + + @Override + protected void validateWildCardTargetLocation(AnnotatedTypeMirror.AnnotatedWildcardType type, Tree tree) { + + InferenceVisitor inferVisitor = (InferenceVisitor) visitor; + if (inferVisitor.getIgnoreTargetLocation()) return; + + AnnotationMirror[] mirrors = new AnnotationMirror[0]; + for (AnnotationMirror am : type.getSuperBound().getAnnotations()) { + inferVisitor.annoIsNoneOf(type, am, + inferVisitor.targetLocationToAnno.get(TypeUseLocation.LOWER_BOUND).toArray(mirrors), + "type.invalid.annotations.on.location", tree); + } + + for (AnnotationMirror am : type.getExtendsBound().getAnnotations()) { + inferVisitor.annoIsNoneOf(type, am, + inferVisitor.targetLocationToAnno.get(TypeUseLocation.UPPER_BOUND).toArray(mirrors), + "type.invalid.annotations.on.location", tree); + } + } } diff --git a/src/checkers/inference/InferenceVisitor.java b/src/checkers/inference/InferenceVisitor.java index c24f01c88..f82f35d1f 100644 --- a/src/checkers/inference/InferenceVisitor.java +++ b/src/checkers/inference/InferenceVisitor.java @@ -6,6 +6,8 @@ import org.checkerframework.common.basetype.BaseAnnotatedTypeFactory; import org.checkerframework.common.basetype.BaseTypeVisitor; import org.checkerframework.common.subtyping.qual.Unqualified; +import org.checkerframework.framework.qual.TargetLocations; +import org.checkerframework.framework.qual.TypeUseLocation; import org.checkerframework.framework.type.AnnotatedTypeMirror; import org.checkerframework.framework.type.AnnotatedTypeMirror.AnnotatedArrayType; import org.checkerframework.framework.type.AnnotatedTypeMirror.AnnotatedDeclaredType; @@ -21,12 +23,15 @@ import java.lang.annotation.Annotation; import java.util.Arrays; +import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Set; import java.util.logging.Logger; import javax.lang.model.element.AnnotationMirror; +import javax.lang.model.element.Element; +import javax.lang.model.element.ElementKind; import javax.lang.model.element.ExecutableElement; import javax.lang.model.type.TypeKind; import javax.lang.model.type.TypeMirror; @@ -46,6 +51,7 @@ import com.sun.source.tree.Tree.Kind; import com.sun.source.tree.VariableTree; +import org.checkerframework.javacutil.TreeUtils; import org.plumelib.util.ArraysPlume; @@ -79,6 +85,12 @@ public class InferenceVisitor> targetLocationToAnno = new HashMap<>(); + public InferenceVisitor(Checker checker, InferenceChecker ichecker, Factory factory, boolean infer) { super((infer) ? ichecker : checker, factory); this.realChecker = checker; @@ -302,7 +314,7 @@ protected void annoIsNot(AnnotatedTypeMirror sourceType, AnnotationMirror effect annoIsNoneOf(sourceType, effectiveAnno, new AnnotationMirror[]{target}, msgKey, node); } - private void annoIsNoneOf(AnnotatedTypeMirror sourceType, AnnotationMirror effectiveAnno, + public void annoIsNoneOf(AnnotatedTypeMirror sourceType, AnnotationMirror effectiveAnno, AnnotationMirror[] targets, String msgKey, Tree node) { if (infer) { final SlotManager slotManager = InferenceMain.getInstance().getSlotManager(); @@ -849,4 +861,87 @@ protected void checkConstructorResult( } } + @Override + protected void initAnnoToTargetLocations() { + // first, init each type-use location contains all type qualifiers + Set> supportQualifiers = atypeFactory.getSupportedTypeQualifiers(); + Set supportedAnnos = AnnotationUtils.createAnnotationSet(); + for (Class ac: supportQualifiers) { + supportedAnnos.add(new AnnotationBuilder( + InferenceMain.getInstance().getRealTypeFactory().getProcessingEnv(), ac).build()); + } + for (TypeUseLocation location : TypeUseLocation.values()) { + targetLocationToAnno.put(location, supportedAnnos); + } + // then, delete some qualifiers which can be applied on that type-use location + // this leaves only qualifiers not allowed on the location. + for (Class qual : supportQualifiers) { + Element elem = elements.getTypeElement(qual.getCanonicalName()); + TargetLocations tls = elem.getAnnotation(TargetLocations.class); + // @Target({ElementType.TYPE_USE})} together with no @TargetLocations(...) means that + // the qualifier can be written on any type use + if (tls == null) { + for (TypeUseLocation location : TypeUseLocation.values()) { + Set amSet = targetLocationToAnno.get(location); + amSet.remove(AnnotationUtils.getAnnotationByName(supportedAnnos, qual.getCanonicalName())); + } + continue; + } + for (TypeUseLocation location : tls.value()) { + Set amSet = targetLocationToAnno.get(location); + amSet.remove(AnnotationUtils.getAnnotationByName(supportedAnnos, qual.getCanonicalName())); + } + } + } + + @Override + protected void validateVariablesTargetLocation(Tree tree, AnnotatedTypeMirror type) { + if (ignoreTargetLocation) return; + Element element = TreeUtils.elementFromTree(tree); + + if (element != null) { + ElementKind elemKind = element.getKind(); + TypeUseLocation location; + switch (elemKind) { + case LOCAL_VARIABLE: + location = TypeUseLocation.LOCAL_VARIABLE; + break; + case EXCEPTION_PARAMETER: + location = TypeUseLocation.EXCEPTION_PARAMETER; + break; + case PARAMETER: + if (((VariableTree) tree).getName().contentEquals("this")) { + location = TypeUseLocation.RECEIVER; + } else { + location = TypeUseLocation.PARAMETER; + } + break; + case RESOURCE_VARIABLE: + location = TypeUseLocation.RESOURCE_VARIABLE; + break; + case FIELD: + location = TypeUseLocation.FIELD; + break; + case ENUM_CONSTANT: + location = TypeUseLocation.CONSTRUCTOR_RESULT; + // TODO: Add ? mainIsNoneOf(type, targetLocationToAnno.get(TypeUseLocation.FIELD).toArray(mirrors), "type.invalid.annotations.on.location", tree); + break; + default: + throw new BugInCF("Location not matched"); + } + AnnotationMirror[] mirrors = new AnnotationMirror[0]; + mainIsNoneOf(type, targetLocationToAnno.get(location).toArray(mirrors), "type.invalid.annotations.on.location", tree); + } + } + + @Override + protected void validateTargetLocation( + Tree tree, AnnotatedTypeMirror type, TypeUseLocation required) { + if (ignoreTargetLocation) { + return; + } + + mainIsNoneOf(type, targetLocationToAnno.get(required).toArray(new AnnotationMirror[0]), + "type.invalid.annotations.on.location", tree); + } } From 44d370e52a7e6d1b7f44d1a5a2e843f2e67cf4d4 Mon Sep 17 00:00:00 2001 From: Haifeng Shi Date: Wed, 21 Dec 2022 11:26:14 -0500 Subject: [PATCH 05/17] use getProcessingEnv --- src/checkers/inference/InferenceVisitor.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/checkers/inference/InferenceVisitor.java b/src/checkers/inference/InferenceVisitor.java index f82f35d1f..023be1bfb 100644 --- a/src/checkers/inference/InferenceVisitor.java +++ b/src/checkers/inference/InferenceVisitor.java @@ -867,8 +867,7 @@ protected void initAnnoToTargetLocations() { Set> supportQualifiers = atypeFactory.getSupportedTypeQualifiers(); Set supportedAnnos = AnnotationUtils.createAnnotationSet(); for (Class ac: supportQualifiers) { - supportedAnnos.add(new AnnotationBuilder( - InferenceMain.getInstance().getRealTypeFactory().getProcessingEnv(), ac).build()); + supportedAnnos.add(new AnnotationBuilder(atypeFactory.getProcessingEnv(), ac).build()); } for (TypeUseLocation location : TypeUseLocation.values()) { targetLocationToAnno.put(location, supportedAnnos); From 105c4b2e39c62917fccc6fbd464e58f1c5a66f71 Mon Sep 17 00:00:00 2001 From: Haifeng Shi Date: Mon, 9 Jan 2023 15:58:07 -0500 Subject: [PATCH 06/17] fix inference initialization crash --- src/checkers/inference/InferenceVisitor.java | 26 +++++++++++++------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/src/checkers/inference/InferenceVisitor.java b/src/checkers/inference/InferenceVisitor.java index 023be1bfb..52063fda3 100644 --- a/src/checkers/inference/InferenceVisitor.java +++ b/src/checkers/inference/InferenceVisitor.java @@ -89,13 +89,14 @@ public class InferenceVisitor> targetLocationToAnno = new HashMap<>(); + protected HashMap> targetLocationToAnno = new HashMap<>(); public InferenceVisitor(Checker checker, InferenceChecker ichecker, Factory factory, boolean infer) { super((infer) ? ichecker : checker, factory); this.realChecker = checker; this.infer = infer; ((InferenceValidator)typeValidator).setInfer(infer); + initTargetLocationToAnno(); } @SuppressWarnings("unchecked") @@ -861,8 +862,7 @@ protected void checkConstructorResult( } } - @Override - protected void initAnnoToTargetLocations() { + protected void initTargetLocationToAnno() { // first, init each type-use location contains all type qualifiers Set> supportQualifiers = atypeFactory.getSupportedTypeQualifiers(); Set supportedAnnos = AnnotationUtils.createAnnotationSet(); @@ -870,7 +870,7 @@ protected void initAnnoToTargetLocations() { supportedAnnos.add(new AnnotationBuilder(atypeFactory.getProcessingEnv(), ac).build()); } for (TypeUseLocation location : TypeUseLocation.values()) { - targetLocationToAnno.put(location, supportedAnnos); + targetLocationToAnno.put(location, new HashSet<>(supportedAnnos)); } // then, delete some qualifiers which can be applied on that type-use location // this leaves only qualifiers not allowed on the location. @@ -895,6 +895,11 @@ protected void initAnnoToTargetLocations() { @Override protected void validateVariablesTargetLocation(Tree tree, AnnotatedTypeMirror type) { + if (!infer) { + super.initAnnoToTargetLocations(); + return; + } + if (ignoreTargetLocation) return; Element element = TreeUtils.elementFromTree(tree); @@ -936,11 +941,14 @@ protected void validateVariablesTargetLocation(Tree tree, AnnotatedTypeMirror ty @Override protected void validateTargetLocation( Tree tree, AnnotatedTypeMirror type, TypeUseLocation required) { - if (ignoreTargetLocation) { - return; + if (!this.infer) { + super.validateTargetLocation(tree, type, required); + } else { + if (ignoreTargetLocation) { + return; + } + mainIsNoneOf(type, targetLocationToAnno.get(required).toArray(new AnnotationMirror[0]), + "type.invalid.annotations.on.location", tree); } - - mainIsNoneOf(type, targetLocationToAnno.get(required).toArray(new AnnotationMirror[0]), - "type.invalid.annotations.on.location", tree); } } From ea3ad2cd0733d9f7b9838a4ead4fa62faf996ce1 Mon Sep 17 00:00:00 2001 From: Haifeng Shi Date: Fri, 13 Jan 2023 16:40:32 -0500 Subject: [PATCH 07/17] disable all targetlocation constraints for the dataflow typesystem --- src/checkers/inference/InferenceVisitor.java | 7 +++++++ src/dataflow/qual/DataFlowInferenceBottom.java | 2 +- src/dataflow/qual/DataFlowTop.java | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/checkers/inference/InferenceVisitor.java b/src/checkers/inference/InferenceVisitor.java index 52063fda3..3ee086d8b 100644 --- a/src/checkers/inference/InferenceVisitor.java +++ b/src/checkers/inference/InferenceVisitor.java @@ -887,6 +887,13 @@ protected void initTargetLocationToAnno() { continue; } for (TypeUseLocation location : tls.value()) { + if (location == TypeUseLocation.ALL) { + for (TypeUseLocation val : TypeUseLocation.values()) { + Set amSet = targetLocationToAnno.get(val); + amSet.remove(AnnotationUtils.getAnnotationByName(supportedAnnos, qual.getCanonicalName())); + } + break; + } Set amSet = targetLocationToAnno.get(location); amSet.remove(AnnotationUtils.getAnnotationByName(supportedAnnos, qual.getCanonicalName())); } diff --git a/src/dataflow/qual/DataFlowInferenceBottom.java b/src/dataflow/qual/DataFlowInferenceBottom.java index 1f3d8e5e7..eed69ce71 100644 --- a/src/dataflow/qual/DataFlowInferenceBottom.java +++ b/src/dataflow/qual/DataFlowInferenceBottom.java @@ -16,7 +16,7 @@ @InvisibleQualifier @SubtypeOf({ DataFlow.class }) @Target({ ElementType.TYPE_USE }) -@TargetLocations({ TypeUseLocation.EXPLICIT_LOWER_BOUND }) +@TargetLocations({ TypeUseLocation.ALL}) public @interface DataFlowInferenceBottom { } diff --git a/src/dataflow/qual/DataFlowTop.java b/src/dataflow/qual/DataFlowTop.java index ad9d6ae69..8c6a0d00c 100644 --- a/src/dataflow/qual/DataFlowTop.java +++ b/src/dataflow/qual/DataFlowTop.java @@ -13,7 +13,7 @@ @InvisibleQualifier @SubtypeOf({}) @Target({ ElementType.TYPE_USE }) -@TargetLocations({ TypeUseLocation.EXPLICIT_UPPER_BOUND }) +@TargetLocations({ TypeUseLocation.ALL }) public @interface DataFlowTop { } \ No newline at end of file From f772bce458c32f33f5ca0231bda58af5ec2159d1 Mon Sep 17 00:00:00 2001 From: Haifeng Shi Date: Mon, 16 Jan 2023 10:11:21 -0500 Subject: [PATCH 08/17] bug fix --- src/checkers/inference/InferenceVisitor.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/checkers/inference/InferenceVisitor.java b/src/checkers/inference/InferenceVisitor.java index 3ee086d8b..a289a8a4f 100644 --- a/src/checkers/inference/InferenceVisitor.java +++ b/src/checkers/inference/InferenceVisitor.java @@ -903,7 +903,7 @@ protected void initTargetLocationToAnno() { @Override protected void validateVariablesTargetLocation(Tree tree, AnnotatedTypeMirror type) { if (!infer) { - super.initAnnoToTargetLocations(); + super.validateVariablesTargetLocation(tree, type); return; } From f1ce7280edd0ae7c1e91c7d26559afdc8c8d36c3 Mon Sep 17 00:00:00 2001 From: Haifeng Shi Date: Tue, 3 Oct 2023 11:43:02 -0400 Subject: [PATCH 09/17] improve comments and readability --- .../inference/InferenceValidator.java | 5 +-- src/checkers/inference/InferenceVisitor.java | 44 ++++++++++++------- .../qual/DataFlowInferenceBottom.java | 2 +- 3 files changed, 30 insertions(+), 21 deletions(-) diff --git a/src/checkers/inference/InferenceValidator.java b/src/checkers/inference/InferenceValidator.java index 9177af611..ccd63cbee 100644 --- a/src/checkers/inference/InferenceValidator.java +++ b/src/checkers/inference/InferenceValidator.java @@ -10,7 +10,6 @@ import org.checkerframework.javacutil.AnnotationUtils; import javax.lang.model.element.AnnotationMirror; -import java.util.List; /** * A visitor to validate the types in a tree. @@ -46,13 +45,13 @@ protected void validateWildCardTargetLocation(AnnotatedTypeMirror.AnnotatedWildc AnnotationMirror[] mirrors = new AnnotationMirror[0]; for (AnnotationMirror am : type.getSuperBound().getAnnotations()) { inferVisitor.annoIsNoneOf(type, am, - inferVisitor.targetLocationToAnno.get(TypeUseLocation.LOWER_BOUND).toArray(mirrors), + inferVisitor.locationToIllegalQuals.get(TypeUseLocation.LOWER_BOUND).toArray(mirrors), "type.invalid.annotations.on.location", tree); } for (AnnotationMirror am : type.getExtendsBound().getAnnotations()) { inferVisitor.annoIsNoneOf(type, am, - inferVisitor.targetLocationToAnno.get(TypeUseLocation.UPPER_BOUND).toArray(mirrors), + inferVisitor.locationToIllegalQuals.get(TypeUseLocation.UPPER_BOUND).toArray(mirrors), "type.invalid.annotations.on.location", tree); } } diff --git a/src/checkers/inference/InferenceVisitor.java b/src/checkers/inference/InferenceVisitor.java index a289a8a4f..30f6c3661 100644 --- a/src/checkers/inference/InferenceVisitor.java +++ b/src/checkers/inference/InferenceVisitor.java @@ -26,6 +26,7 @@ import java.util.HashMap; import java.util.HashSet; import java.util.List; +import java.util.Map; import java.util.Set; import java.util.logging.Logger; @@ -86,17 +87,17 @@ public class InferenceVisitor> targetLocationToAnno = new HashMap<>(); + protected final Map> locationToIllegalQuals; public InferenceVisitor(Checker checker, InferenceChecker ichecker, Factory factory, boolean infer) { super((infer) ? ichecker : checker, factory); this.realChecker = checker; this.infer = infer; ((InferenceValidator)typeValidator).setInfer(infer); - initTargetLocationToAnno(); + locationToIllegalQuals = createMapForIllegalQuals(); } @SuppressWarnings("unchecked") @@ -862,26 +863,32 @@ protected void checkConstructorResult( } } - protected void initTargetLocationToAnno() { - // first, init each type-use location contains all type qualifiers + /** + * This method creates a mapping from type-use locations a lists of qualifiers. + * + * @return A mapping from type-use location to list of qualifiers which cannot be applied to that location. + */ + protected Map> createMapForIllegalQuals() { + Map> locationToIllegalQuals = new HashMap<>(); + // First, init each type-use location to contain all type qualifiers. Set> supportQualifiers = atypeFactory.getSupportedTypeQualifiers(); Set supportedAnnos = AnnotationUtils.createAnnotationSet(); for (Class ac: supportQualifiers) { supportedAnnos.add(new AnnotationBuilder(atypeFactory.getProcessingEnv(), ac).build()); } for (TypeUseLocation location : TypeUseLocation.values()) { - targetLocationToAnno.put(location, new HashSet<>(supportedAnnos)); + locationToIllegalQuals.put(location, new HashSet<>(supportedAnnos)); } - // then, delete some qualifiers which can be applied on that type-use location - // this leaves only qualifiers not allowed on the location. + // Then, delete some qualifiers which can be applied to that type-use location. + // this leaves only qualifiers not allowed on that location. for (Class qual : supportQualifiers) { Element elem = elements.getTypeElement(qual.getCanonicalName()); TargetLocations tls = elem.getAnnotation(TargetLocations.class); // @Target({ElementType.TYPE_USE})} together with no @TargetLocations(...) means that - // the qualifier can be written on any type use + // the qualifier can be written on any type use. if (tls == null) { for (TypeUseLocation location : TypeUseLocation.values()) { - Set amSet = targetLocationToAnno.get(location); + Set amSet = locationToIllegalQuals.get(location); amSet.remove(AnnotationUtils.getAnnotationByName(supportedAnnos, qual.getCanonicalName())); } continue; @@ -889,15 +896,16 @@ protected void initTargetLocationToAnno() { for (TypeUseLocation location : tls.value()) { if (location == TypeUseLocation.ALL) { for (TypeUseLocation val : TypeUseLocation.values()) { - Set amSet = targetLocationToAnno.get(val); + Set amSet = locationToIllegalQuals.get(val); amSet.remove(AnnotationUtils.getAnnotationByName(supportedAnnos, qual.getCanonicalName())); } break; } - Set amSet = targetLocationToAnno.get(location); + Set amSet = locationToIllegalQuals.get(location); amSet.remove(AnnotationUtils.getAnnotationByName(supportedAnnos, qual.getCanonicalName())); } } + return locationToIllegalQuals; } @Override @@ -907,7 +915,9 @@ protected void validateVariablesTargetLocation(Tree tree, AnnotatedTypeMirror ty return; } - if (ignoreTargetLocation) return; + if (ignoreTargetLocation) { + return; + } Element element = TreeUtils.elementFromTree(tree); if (element != null) { @@ -935,13 +945,13 @@ protected void validateVariablesTargetLocation(Tree tree, AnnotatedTypeMirror ty break; case ENUM_CONSTANT: location = TypeUseLocation.CONSTRUCTOR_RESULT; - // TODO: Add ? mainIsNoneOf(type, targetLocationToAnno.get(TypeUseLocation.FIELD).toArray(mirrors), "type.invalid.annotations.on.location", tree); break; default: throw new BugInCF("Location not matched"); } AnnotationMirror[] mirrors = new AnnotationMirror[0]; - mainIsNoneOf(type, targetLocationToAnno.get(location).toArray(mirrors), "type.invalid.annotations.on.location", tree); + mainIsNoneOf(type, locationToIllegalQuals.get(location).toArray(mirrors), + "type.invalid.annotations.on.location", tree); } } @@ -954,7 +964,7 @@ protected void validateTargetLocation( if (ignoreTargetLocation) { return; } - mainIsNoneOf(type, targetLocationToAnno.get(required).toArray(new AnnotationMirror[0]), + mainIsNoneOf(type, locationToIllegalQuals.get(required).toArray(new AnnotationMirror[0]), "type.invalid.annotations.on.location", tree); } } diff --git a/src/dataflow/qual/DataFlowInferenceBottom.java b/src/dataflow/qual/DataFlowInferenceBottom.java index eed69ce71..44a68f37f 100644 --- a/src/dataflow/qual/DataFlowInferenceBottom.java +++ b/src/dataflow/qual/DataFlowInferenceBottom.java @@ -16,7 +16,7 @@ @InvisibleQualifier @SubtypeOf({ DataFlow.class }) @Target({ ElementType.TYPE_USE }) -@TargetLocations({ TypeUseLocation.ALL}) +@TargetLocations({ TypeUseLocation.ALL }) public @interface DataFlowInferenceBottom { } From b2c9722b3c90d3157be0b481370f1ba8e19426eb Mon Sep 17 00:00:00 2001 From: Haifeng Shi Date: Tue, 3 Oct 2023 16:57:37 -0400 Subject: [PATCH 10/17] rename a variable and re-trigger the ci pipeline --- src/checkers/inference/InferenceVisitor.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/checkers/inference/InferenceVisitor.java b/src/checkers/inference/InferenceVisitor.java index 30f6c3661..4e83896cc 100644 --- a/src/checkers/inference/InferenceVisitor.java +++ b/src/checkers/inference/InferenceVisitor.java @@ -873,8 +873,8 @@ protected Map> createMapForIllegalQuals() // First, init each type-use location to contain all type qualifiers. Set> supportQualifiers = atypeFactory.getSupportedTypeQualifiers(); Set supportedAnnos = AnnotationUtils.createAnnotationSet(); - for (Class ac: supportQualifiers) { - supportedAnnos.add(new AnnotationBuilder(atypeFactory.getProcessingEnv(), ac).build()); + for (Class qual: supportQualifiers) { + supportedAnnos.add(new AnnotationBuilder(atypeFactory.getProcessingEnv(), qual).build()); } for (TypeUseLocation location : TypeUseLocation.values()) { locationToIllegalQuals.put(location, new HashSet<>(supportedAnnos)); From b65318986296d91deefb5797effe0fbc3e3475ae Mon Sep 17 00:00:00 2001 From: Aosen Xiong Date: Sun, 31 Mar 2024 00:31:51 -0400 Subject: [PATCH 11/17] Adpat Haifeng's change with new API in CF --- src/checkers/inference/InferenceValidator.java | 2 +- src/checkers/inference/InferenceVisitor.java | 11 ++++------- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/src/checkers/inference/InferenceValidator.java b/src/checkers/inference/InferenceValidator.java index ccd63cbee..ac4acb544 100644 --- a/src/checkers/inference/InferenceValidator.java +++ b/src/checkers/inference/InferenceValidator.java @@ -40,7 +40,7 @@ public void setInfer(boolean infer) { protected void validateWildCardTargetLocation(AnnotatedTypeMirror.AnnotatedWildcardType type, Tree tree) { InferenceVisitor inferVisitor = (InferenceVisitor) visitor; - if (inferVisitor.getIgnoreTargetLocation()) return; + if (inferVisitor.ignoreTargetLocations) return; AnnotationMirror[] mirrors = new AnnotationMirror[0]; for (AnnotationMirror am : type.getSuperBound().getAnnotations()) { diff --git a/src/checkers/inference/InferenceVisitor.java b/src/checkers/inference/InferenceVisitor.java index 4e83896cc..9d21f62c3 100644 --- a/src/checkers/inference/InferenceVisitor.java +++ b/src/checkers/inference/InferenceVisitor.java @@ -17,9 +17,7 @@ import org.checkerframework.framework.type.AnnotatedTypeMirror.AnnotatedWildcardType; import org.checkerframework.framework.type.AnnotatedTypeParameterBounds; import org.checkerframework.framework.util.AnnotatedTypes; -import org.checkerframework.javacutil.AnnotationBuilder; -import org.checkerframework.javacutil.AnnotationUtils; -import org.checkerframework.javacutil.BugInCF; +import org.checkerframework.javacutil.*; import java.lang.annotation.Annotation; import java.util.Arrays; @@ -52,7 +50,6 @@ import com.sun.source.tree.Tree.Kind; import com.sun.source.tree.VariableTree; -import org.checkerframework.javacutil.TreeUtils; import org.plumelib.util.ArraysPlume; @@ -872,7 +869,7 @@ protected Map> createMapForIllegalQuals() Map> locationToIllegalQuals = new HashMap<>(); // First, init each type-use location to contain all type qualifiers. Set> supportQualifiers = atypeFactory.getSupportedTypeQualifiers(); - Set supportedAnnos = AnnotationUtils.createAnnotationSet(); + Set supportedAnnos = new AnnotationMirrorSet(); for (Class qual: supportQualifiers) { supportedAnnos.add(new AnnotationBuilder(atypeFactory.getProcessingEnv(), qual).build()); } @@ -915,7 +912,7 @@ protected void validateVariablesTargetLocation(Tree tree, AnnotatedTypeMirror ty return; } - if (ignoreTargetLocation) { + if (ignoreTargetLocations) { return; } Element element = TreeUtils.elementFromTree(tree); @@ -961,7 +958,7 @@ protected void validateTargetLocation( if (!this.infer) { super.validateTargetLocation(tree, type, required); } else { - if (ignoreTargetLocation) { + if (ignoreTargetLocations) { return; } mainIsNoneOf(type, locationToIllegalQuals.get(required).toArray(new AnnotationMirror[0]), From 4cb067a0d61d3690de1d0b4177becc2e7ef66043 Mon Sep 17 00:00:00 2001 From: Aosen Xiong Date: Fri, 5 Apr 2024 22:12:58 -0700 Subject: [PATCH 12/17] Remove unused script --- scripts/inference-dev | 1 - 1 file changed, 1 deletion(-) diff --git a/scripts/inference-dev b/scripts/inference-dev index 3d587e4fe..c66bc1cb6 100755 --- a/scripts/inference-dev +++ b/scripts/inference-dev @@ -34,7 +34,6 @@ libDir="$cfiDir"/lib CFBuild="${cfDir}"/dataflow/"${classes}":"${cfDir}"/javacutil/"${classes}":"${cfDir}"/framework/"${classes}":"${cfDir}"/framework/"${resources}" CFBuild="${CFBuild}":"${cfDir}"/checker/"${classes}":"${cfDir}"/checker/"${resources}":"${annoToolsDir}"/scene-lib/bin -#CFDepJars="${stubparserDir}"/javaparser-core/target/stubparser-3.25.5.jar:"${afuDir}"/annotation-file-utilities-all.jar CFDepJars="${afuDir}"/annotation-file-utilities-all.jar # sanity check: ensure each jar in CFDepJars actually exists in the file system From 9baba1716665653e9b210c90b837dccd30ad13dc Mon Sep 17 00:00:00 2001 From: Aosen Xiong <82676488+Ao-senXiong@users.noreply.github.com> Date: Sun, 7 Apr 2024 07:55:16 -0700 Subject: [PATCH 13/17] Apply suggestions from code review Co-authored-by: Werner Dietl --- src/checkers/inference/InferenceValidator.java | 4 +++- src/checkers/inference/InferenceVisitor.java | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/checkers/inference/InferenceValidator.java b/src/checkers/inference/InferenceValidator.java index ac4acb544..6b39b76ca 100644 --- a/src/checkers/inference/InferenceValidator.java +++ b/src/checkers/inference/InferenceValidator.java @@ -40,7 +40,9 @@ public void setInfer(boolean infer) { protected void validateWildCardTargetLocation(AnnotatedTypeMirror.AnnotatedWildcardType type, Tree tree) { InferenceVisitor inferVisitor = (InferenceVisitor) visitor; - if (inferVisitor.ignoreTargetLocations) return; + if (inferVisitor.ignoreTargetLocations) { + return; + } AnnotationMirror[] mirrors = new AnnotationMirror[0]; for (AnnotationMirror am : type.getSuperBound().getAnnotations()) { diff --git a/src/checkers/inference/InferenceVisitor.java b/src/checkers/inference/InferenceVisitor.java index 9d21f62c3..e10320542 100644 --- a/src/checkers/inference/InferenceVisitor.java +++ b/src/checkers/inference/InferenceVisitor.java @@ -861,9 +861,9 @@ protected void checkConstructorResult( } /** - * This method creates a mapping from type-use locations a lists of qualifiers. + * This method creates a mapping from type-use locations to a set of qualifiers which cannot be applied to that location. * - * @return A mapping from type-use location to list of qualifiers which cannot be applied to that location. + * @return a mapping from type-use locations to a set of qualifiers which cannot be applied to that location */ protected Map> createMapForIllegalQuals() { Map> locationToIllegalQuals = new HashMap<>(); From f922656892e6b8c41e3413a5956a5da907ad03e4 Mon Sep 17 00:00:00 2001 From: Aosen Xiong Date: Sun, 7 Apr 2024 07:57:50 -0700 Subject: [PATCH 14/17] Undo one change and fix EOF --- .ci-build-without-test.sh | 2 +- src/dataflow/qual/DataFlowTop.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.ci-build-without-test.sh b/.ci-build-without-test.sh index c97363151..3aa0f97f6 100755 --- a/.ci-build-without-test.sh +++ b/.ci-build-without-test.sh @@ -23,7 +23,7 @@ export AFU="${AFU:-../annotation-tools/annotation-file-utilities}" # Don't use `AT=${AFU}/..` which causes a git failure. AT=$(dirname "${AFU}") -# Build annotation-tools (Annotation File Utilities) +## Build annotation-tools (Annotation File Utilities) /tmp/plume-scripts/git-clone-related opprop annotation-tools "${AT}" if [ ! -d ../annotation-tools ] ; then ln -s "${AT}" ../annotation-tools diff --git a/src/dataflow/qual/DataFlowTop.java b/src/dataflow/qual/DataFlowTop.java index 8c6a0d00c..20dc906f6 100644 --- a/src/dataflow/qual/DataFlowTop.java +++ b/src/dataflow/qual/DataFlowTop.java @@ -16,4 +16,4 @@ @TargetLocations({ TypeUseLocation.ALL }) public @interface DataFlowTop { -} \ No newline at end of file +} From 9c7dd3151d7e37f0c73279e025c7d0508816475b Mon Sep 17 00:00:00 2001 From: Aosen Xiong Date: Sun, 7 Apr 2024 08:27:43 -0700 Subject: [PATCH 15/17] Update plume-lib version and use IPair from it --- build.gradle | 2 +- src/checkers/inference/VariableAnnotator.java | 3 +-- .../inference/dataflow/InferenceTransfer.java | 2 +- .../solver/backend/maxsat/MaxSatSolver.java | 13 +++++++------ src/checkers/inference/util/ASTPathUtil.java | 2 +- src/checkers/inference/util/JaifBuilder.java | 2 +- tests/checkers/inference/DataflowInferenceTest.java | 2 +- tests/checkers/inference/IFlowSinkPropTest.java | 2 +- tests/checkers/inference/IFlowSinkSatTest.java | 2 +- tests/checkers/inference/IFlowSourcePropTest.java | 2 +- tests/checkers/inference/IFlowSourceSatTest.java | 2 +- tests/checkers/inference/InterningTest.java | 2 +- tests/checkers/inference/NninfTest.java | 2 +- tests/checkers/inference/OsTrustedTest.java | 2 +- tests/checkers/inference/test/CFInferenceTest.java | 4 ++-- 15 files changed, 22 insertions(+), 22 deletions(-) diff --git a/build.gradle b/build.gradle index d927c23a3..47c39b36a 100644 --- a/build.gradle +++ b/build.gradle @@ -63,7 +63,7 @@ dependencies { implementation group: 'com.google.errorprone', name: 'javac', version: "$errorproneJavacVersion" implementation 'org.plumelib:options:1.0.5' - implementation 'org.plumelib:plume-util:1.5.9' + implementation 'org.plumelib:plume-util:1.8.1' implementation 'com.google.guava:guava:31.1-jre' diff --git a/src/checkers/inference/VariableAnnotator.java b/src/checkers/inference/VariableAnnotator.java index f04e9c8df..b4b48df17 100644 --- a/src/checkers/inference/VariableAnnotator.java +++ b/src/checkers/inference/VariableAnnotator.java @@ -78,8 +78,7 @@ import checkers.inference.util.ASTPathUtil; import checkers.inference.util.CopyUtil; import checkers.inference.util.InferenceUtil; -import org.checkerframework.org.plumelib.util.IPair; - +import org.plumelib.util.IPair; /** * VariableAnnotator takes a type and the tree that the type represents. It determines what locations on the tree diff --git a/src/checkers/inference/dataflow/InferenceTransfer.java b/src/checkers/inference/dataflow/InferenceTransfer.java index 5e3e73302..5ac0f8c5b 100644 --- a/src/checkers/inference/dataflow/InferenceTransfer.java +++ b/src/checkers/inference/dataflow/InferenceTransfer.java @@ -34,7 +34,7 @@ import checkers.inference.model.Slot; import checkers.inference.model.VariableSlot; import checkers.inference.util.InferenceUtil; -import org.checkerframework.org.plumelib.util.IPair; +import org.plumelib.util.IPair; /** * diff --git a/src/checkers/inference/solver/backend/maxsat/MaxSatSolver.java b/src/checkers/inference/solver/backend/maxsat/MaxSatSolver.java index 324302854..2146130fa 100644 --- a/src/checkers/inference/solver/backend/maxsat/MaxSatSolver.java +++ b/src/checkers/inference/solver/backend/maxsat/MaxSatSolver.java @@ -13,6 +13,7 @@ import javax.lang.model.element.AnnotationMirror; import org.checkerframework.javacutil.BugInCF; +import org.plumelib.util.IPair; import org.plumelib.util.Pair; import org.sat4j.core.VecInt; import org.sat4j.maxsat.SolverFactory; @@ -54,7 +55,7 @@ protected enum MaxSatSolverArg implements SolverArg { protected final SlotManager slotManager; protected final List hardClauses = new LinkedList<>(); private List wellFormednessClauses = new LinkedList<>(); - protected final List> softClauses = new LinkedList<>(); + protected final List> softClauses = new LinkedList<>(); private MaxSATUnsatisfiableConstraintExplainer unsatisfiableConstraintExplainer; protected final File CNFData = new File(new File("").getAbsolutePath() + "/cnfData"); protected StringBuilder CNFInput = new StringBuilder(); @@ -145,7 +146,7 @@ public void encodeAllConstraints() { for (VecInt res : encoding) { if (res != null && res.size() != 0) { if (constraint instanceof PreferenceConstraint) { - softClauses.add(new Pair(res, ((PreferenceConstraint) constraint).getWeight())); + softClauses.add(IPair.of(res, ((PreferenceConstraint) constraint).getWeight())); } else { hardClauses.add(res); } @@ -186,8 +187,8 @@ private void addClausesToSolver(WeightedMaxSatDecorator solver) throws Contradic solver.addHardClause(wellFormednessClause); } - for (Pair softclause : softClauses) { - solver.addSoftClause(softclause.b, softclause.a); + for (IPair softclause : softClauses) { + solver.addSoftClause(softclause.second, softclause.first); } } @@ -281,8 +282,8 @@ protected void printClauses() { } System.out.println(); System.out.println("Soft clauses: "); - for (Pair softclause : softClauses) { - System.out.println(softclause.a + " w: " + softclause.b); + for (IPair softclause : softClauses) { + System.out.println(softclause.first + " w: " + softclause.second); } } diff --git a/src/checkers/inference/util/ASTPathUtil.java b/src/checkers/inference/util/ASTPathUtil.java index 156562572..1f4c7f038 100644 --- a/src/checkers/inference/util/ASTPathUtil.java +++ b/src/checkers/inference/util/ASTPathUtil.java @@ -26,7 +26,7 @@ import org.checkerframework.afu.scenelib.io.ASTIndex; import org.checkerframework.afu.scenelib.io.ASTPath; import org.checkerframework.afu.scenelib.io.ASTRecord; -import org.checkerframework.org.plumelib.util.IPair; +import org.plumelib.util.IPair; /** * ASTPathUtil is a collection of utilities to create ASTRecord for existing trees, as well diff --git a/src/checkers/inference/util/JaifBuilder.java b/src/checkers/inference/util/JaifBuilder.java index 014e8df8f..aa0174f53 100644 --- a/src/checkers/inference/util/JaifBuilder.java +++ b/src/checkers/inference/util/JaifBuilder.java @@ -22,7 +22,7 @@ import com.sun.source.tree.Tree; -import org.checkerframework.org.plumelib.util.IPair; +import org.plumelib.util.IPair; /** * JaifBuilder creates Jaifs from a Map of ASTRecords to AnnotationMirrors. diff --git a/tests/checkers/inference/DataflowInferenceTest.java b/tests/checkers/inference/DataflowInferenceTest.java index 46b6047ae..2d4a82cb4 100644 --- a/tests/checkers/inference/DataflowInferenceTest.java +++ b/tests/checkers/inference/DataflowInferenceTest.java @@ -5,7 +5,7 @@ import java.util.List; import org.checkerframework.framework.test.TestUtilities; -import org.checkerframework.org.plumelib.util.IPair; +import org.plumelib.util.IPair; import org.junit.runners.Parameterized.Parameters; import checkers.inference.test.CFInferenceTest; diff --git a/tests/checkers/inference/IFlowSinkPropTest.java b/tests/checkers/inference/IFlowSinkPropTest.java index 7f3745328..fbed0004c 100644 --- a/tests/checkers/inference/IFlowSinkPropTest.java +++ b/tests/checkers/inference/IFlowSinkPropTest.java @@ -2,7 +2,7 @@ import checkers.inference.test.CFInferenceTest; import org.checkerframework.framework.test.TestUtilities; -import org.checkerframework.org.plumelib.util.IPair; +import org.plumelib.util.IPair; import org.junit.runners.Parameterized.Parameters; import sparta.checkers.IFlowSinkChecker; import sparta.checkers.propagation.IFlowSinkSolver; diff --git a/tests/checkers/inference/IFlowSinkSatTest.java b/tests/checkers/inference/IFlowSinkSatTest.java index 7e6d45707..89f8219e5 100644 --- a/tests/checkers/inference/IFlowSinkSatTest.java +++ b/tests/checkers/inference/IFlowSinkSatTest.java @@ -2,7 +2,7 @@ import checkers.inference.test.CFInferenceTest; import org.checkerframework.framework.test.TestUtilities; -import org.checkerframework.org.plumelib.util.IPair; +import org.plumelib.util.IPair; import org.junit.runners.Parameterized.Parameters; import sparta.checkers.IFlowSinkChecker; import sparta.checkers.sat.SinkSolver; diff --git a/tests/checkers/inference/IFlowSourcePropTest.java b/tests/checkers/inference/IFlowSourcePropTest.java index e83b5541c..c48e5a336 100644 --- a/tests/checkers/inference/IFlowSourcePropTest.java +++ b/tests/checkers/inference/IFlowSourcePropTest.java @@ -2,7 +2,7 @@ import checkers.inference.test.CFInferenceTest; import org.checkerframework.framework.test.TestUtilities; -import org.checkerframework.org.plumelib.util.IPair; +import org.plumelib.util.IPair; import org.junit.runners.Parameterized.Parameters; import sparta.checkers.IFlowSourceChecker; import sparta.checkers.propagation.IFlowSourceSolver; diff --git a/tests/checkers/inference/IFlowSourceSatTest.java b/tests/checkers/inference/IFlowSourceSatTest.java index b3a43f197..16fcd997f 100644 --- a/tests/checkers/inference/IFlowSourceSatTest.java +++ b/tests/checkers/inference/IFlowSourceSatTest.java @@ -2,7 +2,7 @@ import checkers.inference.test.CFInferenceTest; import org.checkerframework.framework.test.TestUtilities; -import org.checkerframework.org.plumelib.util.IPair; +import org.plumelib.util.IPair; import org.junit.runners.Parameterized.Parameters; import sparta.checkers.IFlowSourceChecker; import sparta.checkers.sat.SourceSolver; diff --git a/tests/checkers/inference/InterningTest.java b/tests/checkers/inference/InterningTest.java index df0a3f160..77da94088 100644 --- a/tests/checkers/inference/InterningTest.java +++ b/tests/checkers/inference/InterningTest.java @@ -3,7 +3,7 @@ import checkers.inference.solver.MaxSat2TypeSolver; import checkers.inference.test.CFInferenceTest; import org.checkerframework.framework.test.TestUtilities; -import org.checkerframework.org.plumelib.util.IPair; +import org.plumelib.util.IPair; import org.junit.runners.Parameterized.Parameters; import java.io.File; diff --git a/tests/checkers/inference/NninfTest.java b/tests/checkers/inference/NninfTest.java index 1205afc78..a09341ab9 100644 --- a/tests/checkers/inference/NninfTest.java +++ b/tests/checkers/inference/NninfTest.java @@ -3,7 +3,7 @@ import checkers.inference.solver.MaxSat2TypeSolver; import checkers.inference.test.CFInferenceTest; import org.checkerframework.framework.test.TestUtilities; -import org.checkerframework.org.plumelib.util.IPair; +import org.plumelib.util.IPair; import org.junit.runners.Parameterized.Parameters; import java.io.File; diff --git a/tests/checkers/inference/OsTrustedTest.java b/tests/checkers/inference/OsTrustedTest.java index cd8580a0f..73c00f6c2 100644 --- a/tests/checkers/inference/OsTrustedTest.java +++ b/tests/checkers/inference/OsTrustedTest.java @@ -3,7 +3,7 @@ import checkers.inference.solver.MaxSat2TypeSolver; import checkers.inference.test.CFInferenceTest; import org.checkerframework.framework.test.TestUtilities; -import org.checkerframework.org.plumelib.util.IPair; +import org.plumelib.util.IPair; import org.junit.runners.Parameterized.Parameters; import java.io.File; diff --git a/tests/checkers/inference/test/CFInferenceTest.java b/tests/checkers/inference/test/CFInferenceTest.java index e27896c8c..7383b8747 100644 --- a/tests/checkers/inference/test/CFInferenceTest.java +++ b/tests/checkers/inference/test/CFInferenceTest.java @@ -10,8 +10,8 @@ import javax.annotation.processing.AbstractProcessor; -import org.checkerframework.org.plumelib.util.IPair; -import org.checkerframework.org.plumelib.util.SystemPlume; +import org.plumelib.util.IPair; +import org.plumelib.util.SystemPlume; import org.junit.Test; public abstract class CFInferenceTest extends CheckerFrameworkPerFileTest { From 7d092b1b5a11cb998787b724cd3962c39f1e2e61 Mon Sep 17 00:00:00 2001 From: Aosen Xiong Date: Sun, 7 Apr 2024 08:39:14 -0700 Subject: [PATCH 16/17] Remove unused import --- src/checkers/inference/solver/backend/maxsat/MaxSatSolver.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/checkers/inference/solver/backend/maxsat/MaxSatSolver.java b/src/checkers/inference/solver/backend/maxsat/MaxSatSolver.java index 2146130fa..2986f7b23 100644 --- a/src/checkers/inference/solver/backend/maxsat/MaxSatSolver.java +++ b/src/checkers/inference/solver/backend/maxsat/MaxSatSolver.java @@ -14,7 +14,6 @@ import org.checkerframework.javacutil.BugInCF; import org.plumelib.util.IPair; -import org.plumelib.util.Pair; import org.sat4j.core.VecInt; import org.sat4j.maxsat.SolverFactory; import org.sat4j.maxsat.WeightedMaxSatDecorator; From 7818eebbea31fcac3ac237ce8d95034b9a966459 Mon Sep 17 00:00:00 2001 From: Aosen Xiong Date: Sun, 7 Apr 2024 09:02:03 -0700 Subject: [PATCH 17/17] Adapt code to basetype visitor logic --- src/checkers/inference/InferenceVisitor.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/checkers/inference/InferenceVisitor.java b/src/checkers/inference/InferenceVisitor.java index e10320542..7ccd74518 100644 --- a/src/checkers/inference/InferenceVisitor.java +++ b/src/checkers/inference/InferenceVisitor.java @@ -594,7 +594,8 @@ protected boolean commonAssignmentCheck( mono.getCanonicalName(), mono.getCanonicalName(), valueType.toString()); - return true; + // Assign success to false to report the error. + success = false; } } }