use of org.checkerframework.dataflow.analysis.RegularTransferResult in project bazel by bazelbuild.
the class ConstantPropagationTransfer method visitAssignment.
@Override
public TransferResult<Constant, ConstantPropagationStore> visitAssignment(AssignmentNode n, TransferInput<Constant, ConstantPropagationStore> pi) {
ConstantPropagationStore p = pi.getRegularStore();
Node target = n.getTarget();
Constant info = null;
if (target instanceof LocalVariableNode) {
LocalVariableNode t = (LocalVariableNode) target;
info = p.getInformation(n.getExpression());
p.setInformation(t, info);
}
return new RegularTransferResult<>(info, p);
}
use of org.checkerframework.dataflow.analysis.RegularTransferResult in project checker-framework by typetools.
the class CFAbstractTransfer method visitThisLiteral.
@Override
public TransferResult<V, S> visitThisLiteral(ThisLiteralNode n, TransferInput<V, S> in) {
S store = in.getRegularStore();
V valueFromStore = store.getValue(n);
V valueFromFactory = null;
V value = null;
Tree tree = n.getTree();
if (tree != null && TreeUtils.canHaveTypeAnnotation(tree)) {
valueFromFactory = getValueFromFactory(tree, n);
}
if (valueFromFactory == null) {
value = valueFromStore;
} else {
value = moreSpecificValue(valueFromFactory, valueFromStore);
}
return new RegularTransferResult<>(finishValue(value, store), store);
}
use of org.checkerframework.dataflow.analysis.RegularTransferResult in project checker-framework by typetools.
the class FormatterTransfer method visitMethodInvocation.
/**
* Makes it so that the {@link FormatUtil#asFormat} method returns a correctly annotated String.
*/
@Override
public TransferResult<CFValue, CFStore> visitMethodInvocation(MethodInvocationNode node, TransferInput<CFValue, CFStore> in) {
FormatterAnnotatedTypeFactory atypeFactory = (FormatterAnnotatedTypeFactory) analysis.getTypeFactory();
TransferResult<CFValue, CFStore> result = super.visitMethodInvocation(node, in);
FormatterTreeUtil tu = atypeFactory.treeUtil;
if (tu.isAsFormatCall(node, atypeFactory)) {
Result<ConversionCategory[]> cats = tu.asFormatCallCategories(node);
if (cats.value() == null) {
tu.failure(cats, "format.asformat.indirect.arguments");
} else {
AnnotationMirror anno = atypeFactory.treeUtil.categoriesToFormatAnnotation(cats.value());
CFValue newResultValue = analysis.createSingleAnnotationValue(anno, result.getResultValue().getUnderlyingType());
return new RegularTransferResult<>(newResultValue, result.getRegularStore());
}
}
return result;
}
use of org.checkerframework.dataflow.analysis.RegularTransferResult in project checker-framework by typetools.
the class AliasingTransfer method visitAssignment.
/**
* Case 1: For every assignment, the LHS is refined if the RHS has type {@literal @}Unique and is
* a method invocation or a new class instance.
*/
@Override
public TransferResult<CFValue, CFStore> visitAssignment(AssignmentNode n, TransferInput<CFValue, CFStore> in) {
Node rhs = n.getExpression();
Tree treeRhs = rhs.getTree();
AnnotatedTypeMirror rhsType = factory.getAnnotatedType(treeRhs);
if (rhsType.hasAnnotation(Unique.class) && (rhs instanceof MethodInvocationNode || rhs instanceof ObjectCreationNode)) {
// Do normal refinement.
return super.visitAssignment(n, in);
}
// Widen the type of the rhs if the RHS's declared type wasn't @Unique.
JavaExpression rhsExpr = JavaExpression.fromNode(rhs);
in.getRegularStore().clearValue(rhsExpr);
return new RegularTransferResult<>(null, in.getRegularStore());
}
use of org.checkerframework.dataflow.analysis.RegularTransferResult in project checker-framework by typetools.
the class UpperBoundTransfer method visitIntegerLiteral.
@Override
public TransferResult<CFValue, CFStore> visitIntegerLiteral(IntegerLiteralNode n, TransferInput<CFValue, CFStore> pi) {
TransferResult<CFValue, CFStore> result = super.visitIntegerLiteral(n, pi);
int intValue = n.getValue();
AnnotationMirror newAnno;
switch(intValue) {
case 0:
newAnno = atypeFactory.ZERO;
break;
case -1:
newAnno = atypeFactory.NEGATIVEONE;
break;
default:
return result;
}
CFValue c = new CFValue(analysis, Collections.singleton(newAnno), intTM);
return new RegularTransferResult<>(c, result.getRegularStore());
}
Aggregations