Class UpperBoundTransfer
java.lang.Object
org.checkerframework.dataflow.cfg.node.AbstractNodeVisitor<TransferResult<V,S>,TransferInput<V,S>>
   
org.checkerframework.framework.flow.CFAbstractTransfer<CFValue,CFStore,CFTransfer>
  
org.checkerframework.framework.flow.CFTransfer
org.checkerframework.checker.index.IndexAbstractTransfer
org.checkerframework.checker.index.upperbound.UpperBoundTransfer
- All Implemented Interfaces:
- ForwardTransferFunction<CFValue,,- CFStore> - TransferFunction<CFValue,,- CFStore> - NodeVisitor<TransferResult<CFValue,- CFStore>, - TransferInput<CFValue, - CFStore>> 
Contains the transfer functions for the upper bound type system, a part of the Index Checker.
 This class implements the following refinement rules:
 
- 1. Refine the type of expressions used as an array dimension to be less than length of the
       array to which the new array is assigned. For example, in int[] array = new int[expr];, the type of expr is@LTEqLength("array").
- 2. If other * nodehas typetypeOfMultiplication, then ifotheris positive, thennodeistypeOfMultiplication.
- 3. If other * nodehas typetypeOfMultiplication, ifotheris greater than 1, thennodeistypeOfMultiplicationplus 1.
- 4. Given a subtraction node, node, that is known to have typetypeOfSubtraction. An offset can be applied to the left node (i.e. the left node has the same type, but with an offset based on the right node).
- 5. In an addition expression, refine the two operands based on the type of the whole expression with appropriate offsets.
- 6. If an addition expression has a type that is less than length of an array, and one of the operands is non-negative, then the other is less than or equal to the length of the array.
- 7. If an addition expression has a type that is less than length of an array, and one of the operands is positive, then the other is also less than the length of the array.
- 8. if x < y, and y has a type that is related to the length of an array, then x has the same type, with an offset that is one less.
- 9. if x ≤ y, and y has a type that is related to the length of an array, then x has the same type.
- 10. refine the subtrahend in a subtraction which is greater than or equal to a certain offset. The type of the subtrahend is refined to the type of the minuend with the offset added.
- 11. if two variables are equal, they have the same type
- 12. If one node in a != expression is an sequence length field or method access (optionally with a constant offset subtracted) and the other node is less than or equal to that sequence length (minus the offset), then refine the other node's type to less than the sequence length (minus the offset).
- 13. If some Node a is known to be less than the length of some array, x, then, the type of
       a + b, is @LTLengthOf(value="x", offset="-b"). If b is known to be less than the length of some other array, y, then the type of a + b is@LTLengthOf(value={"x", "y"}, offset={"-b", "-a"}).
- 14. If a is known to be less than the length of x when some offset, o, is added to a (the
       type of a is @LTLengthOf(value="x", offset="o")), then the type of a + b is@LTLengthOf(value="x",offset="o - b"). (Note, if "o - b" can be computed, then it is and the result is used in the annotation.)
- 15. If expression i has type @LTLengthOf(value = "f2", offset = "f1.length")int and expression j is less than or equal to the length of f1, then the type of i + j is@LTLengthOf("f2").
- 16. If some Node a is known to be less than the length of some sequence x, then the type of
       a - b is @LTLengthOf(value="x", offset="b").
- 17. If some Node a is known to be less than the length of some sequence x, and if b is non-negative or positive, then a - b should keep the types of a.
- 18. The type of a sequence length access (i.e. array.length) is
       @LTLength(value={"array"...}, offset="-1")where "array"... is the set of all sequences that are the same length (via the SameLen checker) as "array"
- 19. If n is an array length field access, then the type of a.length is the glb of
       @LTEqLengthOf("a")and the value of a.length in the store.
- 20. If n is a String.length() method invocation, then the type of s.length() is the glb of
       @LTEqLengthOf("s")and the value of s.length() in the store.
- 
Field SummaryFields inherited from class org.checkerframework.framework.flow.CFAbstractTransferanalysis, sequentialSemantics
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionprotected voidrefineGT(Node larger, AnnotationMirror largerAnno, Node smaller, AnnotationMirror smallerAnno, CFStore store, TransferInput<CFValue, CFStore> in) Case 8: if x < y, and y has a type that is related to the length of an array, then x has the same type, with an offset that is one less.protected voidrefineGTE(Node left, AnnotationMirror leftAnno, Node right, AnnotationMirror rightAnno, CFStore store, TransferInput<CFValue, CFStore> in) Case 9: if x ≤ y, and y has a type that is related to the length of an array, then x has the same type.protected TransferResult<CFValue,CFStore> strengthenAnnotationOfEqualTo(TransferResult<CFValue, CFStore> res, Node firstNode, Node secondNode, CFValue firstValue, CFValue secondValue, boolean notEqualTo) Implements case 11.visitAssignment(AssignmentNode node, TransferInput<CFValue, CFStore> in) Case 1: Refine the type of expressions used as an array dimension to be less than length of the array to which the new array is assigned.visitCase(CaseNode n, TransferInput<CFValue, CFStore> in) A case produces no value, but it may imply some facts about switch selector expression.If n is an array length field access, then the type of a.length is the glb of @LTEqLengthOf("a") and the value of a.length in the store.If n is a String.length() method invocation, then the type of s.length() is the glb of @LTEqLengthOf("s") and the value of s.length() in the store.If some Node a is known to be less than the length of some array, x, then, the type of a + b, is @LTLengthOf(value="x", offset="-b").If some Node a is known to be less than the length of some sequence x, then the type of a - b is @LTLengthOf(value="x", offset="b").Methods inherited from class org.checkerframework.checker.index.IndexAbstractTransfervisitGreaterThan, visitGreaterThanOrEqual, visitLessThan, visitLessThanOrEqualMethods inherited from class org.checkerframework.framework.flow.CFAbstractTransferaddInformationFromPreconditions, createTransferResult, finishValue, finishValue, getNarrowedValue, getValueFromFactory, getWidenedValue, initialStore, insertIntoStores, isNotFullyInitializedReceiver, moreSpecificValue, processCommonAssignment, processConditionalPostconditions, processPostconditions, recreateTransferResult, setFixedInitialStore, splitAssignments, usesSequentialSemantics, visitArrayAccess, visitClassName, visitConditionalNot, visitEqualTo, visitInstanceOf, visitLambdaResultExpression, visitLocalVariable, visitNarrowingConversion, visitNode, visitNotEqual, visitObjectCreation, visitReturn, visitStringConcatenateAssignment, visitStringConversion, visitSwitchExpressionNode, visitTernaryExpression, visitThis, visitVariableDeclaration, visitWideningConversionMethods inherited from class org.checkerframework.dataflow.cfg.node.AbstractNodeVisitorvisitArrayCreation, visitArrayType, visitAssertionError, visitBitwiseAnd, visitBitwiseComplement, visitBitwiseOr, visitBitwiseXor, visitBooleanLiteral, visitCharacterLiteral, visitClassDeclaration, visitConditionalAnd, visitConditionalOr, visitDoubleLiteral, visitExplicitThis, visitFloatingDivision, visitFloatingRemainder, visitFloatLiteral, visitImplicitThis, visitIntegerDivision, visitIntegerRemainder, visitLeftShift, visitLongLiteral, visitMarker, visitMemberReference, visitMethodAccess, visitNullChk, visitNullLiteral, visitNumericalMinus, visitNumericalMultiplication, visitNumericalPlus, visitPackageName, visitParameterizedType, visitPrimitiveType, visitShortLiteral, visitSignedRightShift, visitStringConcatenate, visitStringLiteral, visitSuper, visitSynchronized, visitThrow, visitTypeCast, visitUnsignedRightShift, visitValueLiteralMethods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.checkerframework.dataflow.cfg.node.NodeVisitorvisitArrayCreation, visitArrayType, visitAssertionError, visitBitwiseAnd, visitBitwiseComplement, visitBitwiseOr, visitBitwiseXor, visitBooleanLiteral, visitCharacterLiteral, visitClassDeclaration, visitConditionalAnd, visitConditionalOr, visitDoubleLiteral, visitExplicitThis, visitFloatingDivision, visitFloatingRemainder, visitFloatLiteral, visitImplicitThis, visitIntegerDivision, visitIntegerRemainder, visitLeftShift, visitLongLiteral, visitMarker, visitMemberReference, visitMethodAccess, visitNullChk, visitNullLiteral, visitNumericalMinus, visitNumericalMultiplication, visitNumericalPlus, visitPackageName, visitParameterizedType, visitPrimitiveType, visitShortLiteral, visitSignedRightShift, visitStringConcatenate, visitStringLiteral, visitSuper, visitSynchronized, visitThrow, visitTypeCast, visitUnsignedRightShift
- 
Constructor Details- 
UpperBoundTransferCreates a new UpperBoundTransfer.- Parameters:
- analysis- the analysis for this transfer function
 
 
- 
- 
Method Details- 
visitAssignmentpublic TransferResult<CFValue,CFStore> visitAssignment(AssignmentNode node, TransferInput<CFValue, CFStore> in) Case 1: Refine the type of expressions used as an array dimension to be less than length of the array to which the new array is assigned. For example, in "int[] array = new int[expr];", the type of expr is @LTEqLength("array").- Specified by:
- visitAssignmentin interface- NodeVisitor<TransferResult<CFValue,- CFStore>, - TransferInput<CFValue, - CFStore>> 
- Overrides:
- visitAssignmentin class- CFAbstractTransfer<CFValue,- CFStore, - CFTransfer> 
 
- 
refineGTprotected void refineGT(Node larger, AnnotationMirror largerAnno, Node smaller, AnnotationMirror smallerAnno, CFStore store, TransferInput<CFValue, CFStore> in) Case 8: if x < y, and y has a type that is related to the length of an array, then x has the same type, with an offset that is one less.- Specified by:
- refineGTin class- IndexAbstractTransfer
 
- 
refineGTEprotected void refineGTE(Node left, AnnotationMirror leftAnno, Node right, AnnotationMirror rightAnno, CFStore store, TransferInput<CFValue, CFStore> in) Case 9: if x ≤ y, and y has a type that is related to the length of an array, then x has the same type.- Specified by:
- refineGTEin class- IndexAbstractTransfer
 
- 
strengthenAnnotationOfEqualToprotected TransferResult<CFValue,CFStore> strengthenAnnotationOfEqualTo(TransferResult<CFValue, CFStore> res, Node firstNode, Node secondNode, CFValue firstValue, CFValue secondValue, boolean notEqualTo) Implements case 11.- Overrides:
- strengthenAnnotationOfEqualToin class- CFAbstractTransfer<CFValue,- CFStore, - CFTransfer> 
- Parameters:
- res- the previous result
- firstNode- the node that might be more precise
- secondNode- the node whose type to possibly refine
- firstValue- the abstract value that might be more precise
- secondValue- the abstract value that might be less precise
- notEqualTo- if true, indicates that the logic is flipped (i.e., the information is added to the- elseStoreinstead of the- thenStore) for a not-equal comparison.
- Returns:
- the conditional transfer result (if information has been added), or null
 
- 
visitNumericalAdditionpublic TransferResult<CFValue,CFStore> visitNumericalAddition(NumericalAdditionNode n, TransferInput<CFValue, CFStore> in) If some Node a is known to be less than the length of some array, x, then, the type of a + b, is @LTLengthOf(value="x", offset="-b"). If b is known to be less than the length of some other array, y, then the type of a + b is @LTLengthOf(value={"x", "y"}, offset={"-b", "-a"}).Alternatively, if a is known to be less than the length of x when some offset, o, is added to a (the type of a is @LTLengthOf(value="x", offset="o")), then the type of a + b is @LTLengthOf(value="x",offset="o - b"). (Note, if "o - b" can be computed, then it is and the result is used in the annotation.) In addition, If expression i has type @LTLengthOf(value = "f2", offset = "f1.length") int and expression j is less than or equal to the length of f1, then the type of i + j is .@LTLengthOf("f2"). These three cases correspond to cases 13-15. - Specified by:
- visitNumericalAdditionin interface- NodeVisitor<TransferResult<CFValue,- CFStore>, - TransferInput<CFValue, - CFStore>> 
- Overrides:
- visitNumericalAdditionin class- AbstractNodeVisitor<TransferResult<CFValue,- CFStore>, - TransferInput<CFValue, - CFStore>> 
 
- 
visitNumericalSubtractionpublic TransferResult<CFValue,CFStore> visitNumericalSubtraction(NumericalSubtractionNode n, TransferInput<CFValue, CFStore> in) If some Node a is known to be less than the length of some sequence x, then the type of a - b is @LTLengthOf(value="x", offset="b"). If b is known to be less than the length of some other sequence, this doesn't add any information about the type of a - b. But, if b is non-negative or positive, then a - b should keep the types of a. This corresponds to cases 16 and 17.- Specified by:
- visitNumericalSubtractionin interface- NodeVisitor<TransferResult<CFValue,- CFStore>, - TransferInput<CFValue, - CFStore>> 
- Overrides:
- visitNumericalSubtractionin class- AbstractNodeVisitor<TransferResult<CFValue,- CFStore>, - TransferInput<CFValue, - CFStore>> 
 
- 
visitFieldAccesspublic TransferResult<CFValue,CFStore> visitFieldAccess(FieldAccessNode n, TransferInput<CFValue, CFStore> in) If n is an array length field access, then the type of a.length is the glb of @LTEqLengthOf("a") and the value of a.length in the store. This is case 19.- Specified by:
- visitFieldAccessin interface- NodeVisitor<TransferResult<CFValue,- CFStore>, - TransferInput<CFValue, - CFStore>> 
- Overrides:
- visitFieldAccessin class- CFAbstractTransfer<CFValue,- CFStore, - CFTransfer> 
 
- 
visitMethodInvocationpublic TransferResult<CFValue,CFStore> visitMethodInvocation(MethodInvocationNode n, TransferInput<CFValue, CFStore> in) If n is a String.length() method invocation, then the type of s.length() is the glb of @LTEqLengthOf("s") and the value of s.length() in the store. This is case 20.- Specified by:
- visitMethodInvocationin interface- NodeVisitor<TransferResult<CFValue,- CFStore>, - TransferInput<CFValue, - CFStore>> 
- Overrides:
- visitMethodInvocationin class- CFAbstractTransfer<CFValue,- CFStore, - CFTransfer> 
 
- 
visitCaseDescription copied from class:CFAbstractTransferA case produces no value, but it may imply some facts about switch selector expression.- Specified by:
- visitCasein interface- NodeVisitor<TransferResult<CFValue,- CFStore>, - TransferInput<CFValue, - CFStore>> 
- Overrides:
- visitCasein class- CFAbstractTransfer<CFValue,- CFStore, - CFTransfer> 
 
- 
visitIntegerLiteralpublic TransferResult<CFValue,CFStore> visitIntegerLiteral(IntegerLiteralNode n, TransferInput<CFValue, CFStore> pi) - Specified by:
- visitIntegerLiteralin interface- NodeVisitor<TransferResult<CFValue,- CFStore>, - TransferInput<CFValue, - CFStore>> 
- Overrides:
- visitIntegerLiteralin class- AbstractNodeVisitor<TransferResult<CFValue,- CFStore>, - TransferInput<CFValue, - CFStore>> 
 
 
-