Class UpperBoundVisitor
java.lang.Object
com.sun.source.util.TreeScanner<R,P>
 
com.sun.source.util.TreePathScanner<R,P>
 
org.checkerframework.framework.source.SourceVisitor<Void,Void>
 
org.checkerframework.common.basetype.BaseTypeVisitor<UpperBoundAnnotatedTypeFactory>
org.checkerframework.checker.index.upperbound.UpperBoundVisitor
- All Implemented Interfaces:
- TreeVisitor<Void,- Void> 
Warns about array accesses that could be too high.
- 
Nested Class SummaryNested classes/interfaces inherited from class org.checkerframework.common.basetype.BaseTypeVisitorBaseTypeVisitor.OverrideChecker
- 
Field SummaryFields inherited from class org.checkerframework.common.basetype.BaseTypeVisitoratypeFactory, checker, DETERMINISTIC, IMPURE, methodTree, positions, PURE, qualHierarchy, showchecks, SIDE_EFFECT_FREE, TARGET, targetValueElement, typeHierarchy, typeValidator, unusedWhenElementFields inherited from class org.checkerframework.framework.source.SourceVisitorelements, root, trees, treesWithSuppressWarnings, types
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionprotected booleancommonAssignmentCheck(Tree varTree, ExpressionTree valueTree, @CompilerMessageKey String errorKey, Object... extraArgs) Checks the validity of an assignment (or pseudo-assignment) from a value to a variable and emits an error message (through the compiler's messaging interface) if it is not valid.protected booleancommonAssignmentCheck(AnnotatedTypeMirror varType, ExpressionTree valueTree, @CompilerMessageKey String errorKey, Object... extraArgs) Checks the validity of an assignment (or pseudo-assignment) from a value to a variable and emits an error message (through the compiler's messaging interface) if it is not valid.visitAnnotation(AnnotationTree tree, Void p) Warns about LTLengthOf annotations with arguments whose lengths do not match.visitArrayAccess(ArrayAccessTree tree, Void type) When the visitor reaches an array access, it needs to check a couple of things.Methods inherited from class org.checkerframework.common.basetype.BaseTypeVisitorcheckAccess, checkAccessAllowed, checkArguments, checkArrayInitialization, checkConditionalPostcondition, checkConstructorInvocation, checkConstructorResult, checkContract, checkDefaultConstructor, checkExceptionParameter, checkExplicitAnnotationsOnIntersectionBounds, checkExtendsAndImplements, checkExtendsOrImplements, checkFieldInvariantDeclarations, checkForPolymorphicQualifiers, checkForPolymorphicQualifiers, checkMethodInvocability, checkMethodReferenceAsOverride, checkOverride, checkOverride, checkPostcondition, checkPreconditions, checkPurity, checkQualifierParameter, checkSuperConstructorCall, checkThisConstructorCall, checkThisOrSuperConstructorCall, checkThrownExpression, checkTypeArguments, checkTypecastRedundancy, checkTypecastSafety, checkVarargs, commonAssignmentCheck, commonAssignmentCheckEndDiagnostic, commonAssignmentCheckEndDiagnostic, commonAssignmentCheckStartDiagnostic, createOverrideChecker, createTypeFactory, createTypeFactoryPublic, createTypeValidator, enclosingMemberSelect, enclosingStatement, getExceptionParameterLowerBoundAnnotations, getThrowUpperBoundAnnotations, getTypeFactory, isTypeCastSafe, isValidUse, isValidUse, isValidUse, processClassTree, reportMethodInvocabilityError, reportPurityErrors, scan, setRoot, shouldSkipUses, shouldWarnAboutIrrelevantJavaTypes, skipReceiverSubtypeCheck, testAnnotationInsertion, testJointJavacJavaParserVisitor, testTypevarContainment, typeCheckVectorCopyIntoArgument, validateType, validateTypeOf, visitAnnotatedType, visitAnnotatedType, visitAssignment, visitCatch, visitClass, visitCompilationUnit, visitCompoundAssignment, visitConditionalExpression, visitEnhancedForLoop, visitIdentifier, visitInstanceOf, visitLambdaExpression, visitMemberReference, visitMethod, visitMethodInvocation, visitNewArray, visitNewClass, visitReturn, visitSwitchExpression17, visitThrow, visitTypeCast, visitTypeParameter, visitUnary, visitVariable, warnAboutIrrelevantJavaTypes, warnRedundantAnnotationsMethods inherited from class org.checkerframework.framework.source.SourceVisitorvisitMethods inherited from class com.sun.source.util.TreePathScannergetCurrentPath, scanMethods inherited from class com.sun.source.util.TreeScannerreduce, scan, visitArrayType, visitAssert, visitBinary, visitBindingPattern, visitBlock, visitBreak, visitCase, visitContinue, visitDefaultCaseLabel, visitDoWhileLoop, visitEmptyStatement, visitErroneous, visitExports, visitExpressionStatement, visitForLoop, visitGuardedPattern, visitIf, visitImport, visitIntersectionType, visitLabeledStatement, visitLiteral, visitMemberSelect, visitModifiers, visitModule, visitOpens, visitOther, visitPackage, visitParameterizedType, visitParenthesized, visitParenthesizedPattern, visitPrimitiveType, visitProvides, visitRequires, visitSwitch, visitSwitchExpression, visitSynchronized, visitTry, visitUnionType, visitUses, visitWhileLoop, visitWildcard, visitYield
- 
Constructor Details- 
UpperBoundVisitor
 
- 
- 
Method Details- 
visitArrayAccessWhen the visitor reaches an array access, it needs to check a couple of things. First, it checks if the index has been assigned a reasonable UpperBound type: only an index with type LTLengthOf(arr) is safe to access arr. If that fails, it checks if the access is still safe. To do so, it checks if the Value Checker knows the minimum length of arr by querying the Value Annotated Type Factory. If the minimum length of the array is known, the visitor can check if the index is less than that minimum length. If so, then the access is still safe. Otherwise, report a potential unsafe access.- Specified by:
- visitArrayAccessin interface- TreeVisitor<Void,- Void> 
- Overrides:
- visitArrayAccessin class- TreeScanner<Void,- Void> 
 
- 
visitAnnotationWarns about LTLengthOf annotations with arguments whose lengths do not match.- Specified by:
- visitAnnotationin interface- TreeVisitor<Void,- Void> 
- Overrides:
- visitAnnotationin class- BaseTypeVisitor<UpperBoundAnnotatedTypeFactory>
 
- 
commonAssignmentCheckprotected boolean commonAssignmentCheck(Tree varTree, ExpressionTree valueTree, @CompilerMessageKey String errorKey, Object... extraArgs) Description copied from class:BaseTypeVisitorChecks the validity of an assignment (or pseudo-assignment) from a value to a variable and emits an error message (through the compiler's messaging interface) if it is not valid.- Overrides:
- commonAssignmentCheckin class- BaseTypeVisitor<UpperBoundAnnotatedTypeFactory>
- Parameters:
- varTree- the AST node for the lvalue (usually a variable)
- valueTree- the AST node for the rvalue (the new value)
- errorKey- the error message key to use if the check fails
- extraArgs- arguments to the error message key, before "found" and "expected" types
- Returns:
- true if the check succeeds, false if an error message was issued
 
- 
commonAssignmentCheckprotected boolean commonAssignmentCheck(AnnotatedTypeMirror varType, ExpressionTree valueTree, @CompilerMessageKey String errorKey, Object... extraArgs) Description copied from class:BaseTypeVisitorChecks the validity of an assignment (or pseudo-assignment) from a value to a variable and emits an error message (through the compiler's messaging interface) if it is not valid.- Overrides:
- commonAssignmentCheckin class- BaseTypeVisitor<UpperBoundAnnotatedTypeFactory>
- Parameters:
- varType- the annotated type for the lvalue (usually a variable)
- valueTree- the AST node for the rvalue (the new value)
- errorKey- the error message key to use if the check fails
- extraArgs- arguments to the error message key, before "found" and "expected" types
- Returns:
- true if the check succeeds, false if an error message was issued
 
 
-