use of org.checkerframework.dataflow.analysis.RegularTransferResult in project checker-framework by typetools.
the class ValueTransfer method createNewResultBoolean.
/**
* Create a boolean transfer result.
*/
private TransferResult<CFValue, CFStore> createNewResultBoolean(CFStore thenStore, CFStore elseStore, List<Boolean> resultValues, TypeMirror underlyingType) {
AnnotationMirror boolVal = atypeFactory.createBooleanAnnotation(resultValues);
CFValue newResultValue = analysis.createSingleAnnotationValue(boolVal, underlyingType);
if (elseStore != null) {
return new ConditionalTransferResult<>(newResultValue, thenStore, elseStore);
} else {
return new RegularTransferResult<>(newResultValue, thenStore);
}
}
use of org.checkerframework.dataflow.analysis.RegularTransferResult in project checker-framework by typetools.
the class I18nFormatterTransfer method visitMethodInvocation.
@Override
public TransferResult<CFValue, CFStore> visitMethodInvocation(MethodInvocationNode node, TransferInput<CFValue, CFStore> in) {
I18nFormatterAnnotatedTypeFactory atypeFactory = (I18nFormatterAnnotatedTypeFactory) analysis.getTypeFactory();
TransferResult<CFValue, CFStore> result = super.visitMethodInvocation(node, in);
I18nFormatterTreeUtil tu = atypeFactory.treeUtil;
// If hasFormat is called, make sure that the format string is annotated correctly
if (tu.isHasFormatCall(node, atypeFactory)) {
CFStore thenStore = result.getRegularStore();
CFStore elseStore = thenStore.copy();
ConditionalTransferResult<CFValue, CFStore> newResult = new ConditionalTransferResult<>(result.getResultValue(), thenStore, elseStore);
Result<I18nConversionCategory[]> cats = tu.getHasFormatCallCategories(node);
if (cats.value() == null) {
tu.failure(cats, "i18nformat.indirect.arguments");
} else {
JavaExpression firstParam = JavaExpression.fromNode(node.getArgument(0));
AnnotationMirror anno = atypeFactory.treeUtil.categoriesToFormatAnnotation(cats.value());
thenStore.insertValue(firstParam, anno);
}
return newResult;
}
// If isFormat is called, annotate the format string with I18nInvalidFormat
if (tu.isIsFormatCall(node, atypeFactory)) {
CFStore thenStore = result.getRegularStore();
CFStore elseStore = thenStore.copy();
ConditionalTransferResult<CFValue, CFStore> newResult = new ConditionalTransferResult<>(result.getResultValue(), thenStore, elseStore);
JavaExpression firstParam = JavaExpression.fromNode(node.getArgument(0));
AnnotationBuilder builder = new AnnotationBuilder(tu.processingEnv, I18nInvalidFormat.class);
// No need to set a value of @I18nInvalidFormat
builder.setValue("value", "");
elseStore.insertValue(firstParam, builder.build());
return newResult;
}
// corresponding key's value.
if (tu.isMakeFormatCall(node, atypeFactory)) {
Result<I18nConversionCategory[]> cats = tu.makeFormatCallCategories(node, atypeFactory);
if (cats.value() == null) {
tu.failure(cats, "i18nformat.key.not.found");
} 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 LiveVarTransfer method visitReturn.
@Override
public RegularTransferResult<LiveVarValue, LiveVarStore> visitReturn(ReturnNode n, TransferInput<LiveVarValue, LiveVarStore> p) {
RegularTransferResult<LiveVarValue, LiveVarStore> transferResult = (RegularTransferResult<LiveVarValue, LiveVarStore>) super.visitReturn(n, p);
Node result = n.getResult();
if (result != null) {
LiveVarStore store = transferResult.getRegularStore();
store.addUseInExpression(result);
}
return transferResult;
}
use of org.checkerframework.dataflow.analysis.RegularTransferResult in project checker-framework by typetools.
the class LiveVarTransfer method visitMethodInvocation.
@Override
public RegularTransferResult<LiveVarValue, LiveVarStore> visitMethodInvocation(MethodInvocationNode n, TransferInput<LiveVarValue, LiveVarStore> p) {
RegularTransferResult<LiveVarValue, LiveVarStore> transferResult = (RegularTransferResult<LiveVarValue, LiveVarStore>) super.visitMethodInvocation(n, p);
LiveVarStore store = transferResult.getRegularStore();
for (Node arg : n.getArguments()) {
store.addUseInExpression(arg);
}
return transferResult;
}
use of org.checkerframework.dataflow.analysis.RegularTransferResult in project checker-framework by typetools.
the class CFAbstractTransfer method visitThis.
@Override
public TransferResult<V, S> visitThis(ThisNode 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);
}
Aggregations