use of org.checkerframework.dataflow.cfg.node.AssignmentNode in project bazel by bazelbuild.
the class Analysis method callTransferFunction.
/**
* Call the transfer function for node {@code node}, and set that node as
* current node first.
*/
protected TransferResult<A, S> callTransferFunction(Node node, TransferInput<A, S> store) {
if (node.isLValue()) {
// store.hasTwoStores()), or is the following correct?
return new RegularTransferResult<A, S>(null, store.getRegularStore());
}
store.node = node;
currentNode = node;
TransferResult<A, S> transferResult = node.accept(transferFunction, store);
currentNode = null;
if (node instanceof ReturnNode) {
// save a copy of the store to later check if some property held at
// a given return statement
storesAtReturnStatements.put((ReturnNode) node, transferResult);
}
if (node instanceof AssignmentNode) {
// store the flow-refined value for effectively final local variables
AssignmentNode assignment = (AssignmentNode) node;
Node lhst = assignment.getTarget();
if (lhst instanceof LocalVariableNode) {
LocalVariableNode lhs = (LocalVariableNode) lhst;
Element elem = lhs.getElement();
if (ElementUtils.isEffectivelyFinal(elem)) {
finalLocalValues.put(elem, transferResult.getResultValue());
}
}
}
return transferResult;
}
use of org.checkerframework.dataflow.cfg.node.AssignmentNode 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.cfg.node.AssignmentNode in project error-prone by google.
the class NullnessPropagationTransfer method visitAssignment.
@Override
Nullness visitAssignment(AssignmentNode node, SubNodeValues inputs, LocalVariableUpdates updates) {
Nullness value = inputs.valueOfSubNode(node.getExpression());
Node target = node.getTarget();
if (target instanceof LocalVariableNode) {
updates.set((LocalVariableNode) target, value);
}
if (target instanceof ArrayAccessNode) {
setNonnullIfLocalVariable(updates, ((ArrayAccessNode) target).getArray());
}
if (target instanceof FieldAccessNode) {
FieldAccessNode fieldAccess = (FieldAccessNode) target;
ClassAndField targetField = tryGetFieldSymbol(target.getTree());
setReceiverNonnull(updates, fieldAccess.getReceiver(), targetField);
}
/*
* We propagate the value of the target to the value of the assignment expressions as a whole.
* We do this regardless of whether the target is a local variable. For example:
*
* String s = object.field = "foo"; // Now |s| is non-null.
*
* It's not clear to me that this is technically correct, but it works in practice with the
* bytecode generated by both javac and ecj.
*
* http://stackoverflow.com/q/12850676/28465
*/
return value;
}
Aggregations