use of org.checkerframework.dataflow.cfg.node.MethodInvocationNode in project checker-framework by typetools.
the class ValueTransfer method processConditionalPostconditions.
@Override
protected void processConditionalPostconditions(MethodInvocationNode n, ExecutableElement methodElement, Tree tree, CFStore thenStore, CFStore elseStore) {
// For String.startsWith(String) and String.endsWith(String), refine the minimum length
// of the receiver to the minimum length of the argument.
ValueMethodIdentifier methodIdentifier = atypeFactory.getMethodIdentifier();
if (methodIdentifier.isStartsWithMethod(methodElement) || methodIdentifier.isEndsWithMethod(methodElement)) {
Node argumentNode = n.getArgument(0);
AnnotationMirror argumentAnno = getArrayOrStringAnnotation(argumentNode);
int minLength = atypeFactory.getMinLenValue(argumentAnno);
// Update the annotation of the receiver
if (minLength != 0) {
JavaExpression receiver = JavaExpression.fromNode(n.getTarget().getReceiver());
AnnotationMirror minLenAnno = atypeFactory.createArrayLenRangeAnnotation(minLength, Integer.MAX_VALUE);
thenStore.insertValuePermitNondeterministic(receiver, minLenAnno);
}
}
super.processConditionalPostconditions(n, methodElement, tree, thenStore, elseStore);
}
use of org.checkerframework.dataflow.cfg.node.MethodInvocationNode in project checker-framework by typetools.
the class ValueTransfer method refineAtLengthInvocation.
/**
* If length method is invoked for a sequence, transform its @IntVal annotation into an @ArrayLen
* annotation.
*
* @param lengthNode the length method invocation node
* @param store the Checker Framework store
*/
private void refineAtLengthInvocation(MethodInvocationNode lengthNode, CFStore store) {
if (atypeFactory.getMethodIdentifier().isStringLengthMethod(lengthNode.getTarget().getMethod())) {
MethodAccessNode methodAccessNode = lengthNode.getTarget();
refineAtLengthAccess(lengthNode, methodAccessNode.getReceiver(), store);
} else if (atypeFactory.getMethodIdentifier().isArrayGetLengthMethod(lengthNode.getTarget().getMethod())) {
Node node = lengthNode.getArguments().get(0);
refineAtLengthAccess(lengthNode, node, store);
}
}
Aggregations