public class AliasingVisitor extends BaseTypeVisitor<AliasingAnnotatedTypeFactory>
TODO: Implement @NonLeaked and @LeakedToResult verifications:
@NonLeaked: When a method declaration has a parameter annotated as @NonLeaked, the method body must not leak a reference to that parameter.
@LeakedToResult: When a method declaration has a parameter annotated as @LeakedToResult, the method body must not leak a reference to that parameter, except at the method return statements.
Both of the checks above are similar to the @Unique check that is implemented in this visitor.
BaseTypeVisitor.OverrideCheckeratypeFactory, checker, contractsUtils, positions, typeValidator, visitorStateelements, root, trees, types| Constructor and Description |
|---|
AliasingVisitor(BaseTypeChecker checker) |
| Modifier and Type | Method and Description |
|---|---|
protected void |
commonAssignmentCheck(AnnotatedTypeMirror varType,
AnnotatedTypeMirror valueType,
com.sun.source.tree.Tree valueTree,
@CompilerMessageKey java.lang.String errorKey)
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 void |
commonAssignmentCheck(com.sun.source.tree.Tree varTree,
com.sun.source.tree.ExpressionTree valueExp,
@CompilerMessageKey java.lang.String errorKey)
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.
|
java.lang.Void |
visitMethodInvocation(com.sun.source.tree.MethodInvocationTree node,
java.lang.Void p)
Checks that if a method call is being invoked inside a constructor with result type
@Unique, it must not leak the "this" reference.
|
java.lang.Void |
visitNewArray(com.sun.source.tree.NewArrayTree node,
java.lang.Void p) |
java.lang.Void |
visitThrow(com.sun.source.tree.ThrowTree node,
java.lang.Void p)
Checks the type of a thrown exception.
|
java.lang.Void |
visitVariable(com.sun.source.tree.VariableTree node,
java.lang.Void p) |
checkAccess, checkArguments, checkArrayInitialization, checkAssignability, checkConditionalPostcondition, checkConstructorInvocation, checkContract, checkDefaultConstructor, checkExceptionParameter, checkFieldInvariantDeclarations, checkForAnnotatedJdk, checkMethodInvocability, checkMethodReferenceAsOverride, checkOverride, checkOverride, checkPostcondition, checkPreconditions, checkThrownExpression, checkTypeArguments, checkTypecastRedundancy, checkTypecastSafety, checkVarargs, commonAssignmentCheck, createOverrideChecker, createTypeFactory, createTypeValidator, enclosingMemberSelect, enclosingStatement, getExceptionParameterLowerBoundAnnotations, getThrowUpperBoundAnnotations, getTypeFactory, isAccessAllowed, isAssignable, isValidUse, isValidUse, isValidUse, isVectorCopyInto, processClassTree, reportPurityErrors, scan, setRoot, shouldSkipUses, skipReceiverSubtypeCheck, testTypevarContainment, typeCheckVectorCopyIntoArgument, validateType, validateTypeOf, visitAnnotation, visitArrayAccess, visitAssignment, visitCatch, visitClass, visitCompilationUnit, visitCompoundAssignment, visitConditionalExpression, visitEnhancedForLoop, visitIdentifier, visitInstanceOf, visitLambdaExpression, visitMemberReference, visitMethod, visitNewClass, visitParameterizedType, visitReturn, visitTry, visitTypeCast, visitTypeParameter, visitUnaryvisitreduce, scan, visitAnnotatedType, visitArrayType, visitAssert, visitBinary, visitBlock, visitBreak, visitCase, visitContinue, visitDoWhileLoop, visitEmptyStatement, visitErroneous, visitExpressionStatement, visitForLoop, visitIf, visitImport, visitIntersectionType, visitLabeledStatement, visitLiteral, visitMemberSelect, visitModifiers, visitOther, visitParenthesized, visitPrimitiveType, visitSwitch, visitSynchronized, visitUnionType, visitWhileLoop, visitWildcardpublic AliasingVisitor(BaseTypeChecker checker)
public java.lang.Void visitMethodInvocation(com.sun.source.tree.MethodInvocationTree node,
java.lang.Void p)
this is not an argument of the method call.
this is an argument of the method call, but the respective parameter is
annotated as @NonLeaked.
this is an argument of the method call, but the respective parameter is
annotated as @LeakedToResult AND the result of the method call is not being
stored (the method call is a statement).
isUniqueCheck handles cases 2 and 3.visitMethodInvocation in interface com.sun.source.tree.TreeVisitor<java.lang.Void,java.lang.Void>visitMethodInvocation in class BaseTypeVisitor<AliasingAnnotatedTypeFactory>protected void commonAssignmentCheck(com.sun.source.tree.Tree varTree,
com.sun.source.tree.ExpressionTree valueExp,
@CompilerMessageKey java.lang.String errorKey)
BaseTypeVisitorcommonAssignmentCheck in class BaseTypeVisitor<AliasingAnnotatedTypeFactory>varTree - the AST node for the lvalue (usually a variable)valueExp - the AST node for the rvalue (the new value)errorKey - the error message to use if the check fails (must be a compiler message key,
see CompilerMessageKey)protected void commonAssignmentCheck(AnnotatedTypeMirror varType, AnnotatedTypeMirror valueType, com.sun.source.tree.Tree valueTree, @CompilerMessageKey java.lang.String errorKey)
BaseTypeVisitorcommonAssignmentCheck in class BaseTypeVisitor<AliasingAnnotatedTypeFactory>varType - the annotated type of the variablevalueType - the annotated type of the valuevalueTree - the location to use when reporting the error messageerrorKey - the error message to use if the check fails (must be a compiler message key,
see CompilerMessageKey)public java.lang.Void visitThrow(com.sun.source.tree.ThrowTree node,
java.lang.Void p)
BaseTypeVisitorvisitThrow in interface com.sun.source.tree.TreeVisitor<java.lang.Void,java.lang.Void>visitThrow in class BaseTypeVisitor<AliasingAnnotatedTypeFactory>public java.lang.Void visitVariable(com.sun.source.tree.VariableTree node,
java.lang.Void p)
visitVariable in interface com.sun.source.tree.TreeVisitor<java.lang.Void,java.lang.Void>visitVariable in class BaseTypeVisitor<AliasingAnnotatedTypeFactory>public java.lang.Void visitNewArray(com.sun.source.tree.NewArrayTree node,
java.lang.Void p)
visitNewArray in interface com.sun.source.tree.TreeVisitor<java.lang.Void,java.lang.Void>visitNewArray in class BaseTypeVisitor<AliasingAnnotatedTypeFactory>