Class CalledMethodsTransfer
- All Implemented Interfaces:
ForwardTransferFunction<AccumulationValue,
,AccumulationStore> TransferFunction<AccumulationValue,
,AccumulationStore> NodeVisitor<TransferResult<AccumulationValue,
AccumulationStore>, TransferInput<AccumulationValue, AccumulationStore>>
- Direct Known Subclasses:
ResourceLeakTransfer
-
Field Summary
Fields inherited from class org.checkerframework.common.accumulation.AccumulationTransfer
atypeFactory
Fields inherited from class org.checkerframework.framework.flow.CFAbstractTransfer
analysis, sequentialSemantics
-
Constructor Summary
ConstructorDescriptionCalledMethodsTransfer
(CalledMethodsAnalysis analysis) Create a new CalledMethodsTransfer. -
Method Summary
Modifier and TypeMethodDescriptionvoid
accumulate
(Node node, TransferResult<AccumulationValue, AccumulationStore> result, String... values) Updates the estimate of how many thingsnode
has accumulated.protected boolean
Checks if WPI is enabled for the Resource Leak Checker inference.protected boolean
Returns true if whole-program inference should be performed.protected boolean
shouldPerformWholeProgramInference
(Tree expressionTree, Tree lhsTree) visitMethodInvocation
(MethodInvocationNode node, TransferInput<AccumulationValue, AccumulationStore> input) Methods inherited from class org.checkerframework.framework.flow.CFAbstractTransfer
addInformationFromPreconditions, createTransferResult, createTransferResult, finishValue, finishValue, getNarrowedValue, getValueFromFactory, getWidenedValue, initialStore, insertIntoStores, isNotFullyInitializedReceiver, moreSpecificValue, processCommonAssignment, processConditionalPostconditions, processPostconditions, recreateTransferResult, recreateTransferResult, setFixedInitialStore, splitAssignments, strengthenAnnotationOfEqualTo, usesSequentialSemantics, visitArrayAccess, visitAssignment, visitCase, visitClassName, visitConditionalNot, visitDeconstructorPattern, visitEqualTo, visitExpressionStatement, visitFieldAccess, visitInstanceOf, visitLambdaResultExpression, visitLocalVariable, visitNarrowingConversion, visitNode, visitNotEqual, visitObjectCreation, visitReturn, visitStringConversion, visitSwitchExpressionNode, visitTernaryExpression, visitThis, visitVariableDeclaration, visitWideningConversion
Methods inherited from class org.checkerframework.dataflow.cfg.node.AbstractNodeVisitor
visitArrayCreation, visitArrayType, visitAssertionError, visitBitwiseAnd, visitBitwiseComplement, visitBitwiseOr, visitBitwiseXor, visitBooleanLiteral, visitCharacterLiteral, visitClassDeclaration, visitConditionalAnd, visitConditionalOr, visitDoubleLiteral, visitExplicitThis, visitFloatingDivision, visitFloatingRemainder, visitFloatLiteral, visitGreaterThan, visitGreaterThanOrEqual, visitImplicitThis, visitIntegerDivision, visitIntegerLiteral, visitIntegerRemainder, visitLeftShift, visitLessThan, visitLessThanOrEqual, visitLongLiteral, visitMarker, visitMemberReference, visitMethodAccess, visitNullChk, visitNullLiteral, visitNumericalAddition, visitNumericalMinus, visitNumericalMultiplication, visitNumericalPlus, visitNumericalSubtraction, visitPackageName, visitParameterizedType, visitPrimitiveType, visitShortLiteral, visitSignedRightShift, visitStringConcatenate, visitStringLiteral, visitSuper, visitSynchronized, visitThrow, visitTypeCast, visitUnsignedRightShift, visitValueLiteral
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.checkerframework.dataflow.cfg.node.NodeVisitor
visitArrayCreation, visitArrayType, visitAssertionError, visitBitwiseAnd, visitBitwiseComplement, visitBitwiseOr, visitBitwiseXor, visitBooleanLiteral, visitCharacterLiteral, visitClassDeclaration, visitConditionalAnd, visitConditionalOr, visitDoubleLiteral, visitExplicitThis, visitFloatingDivision, visitFloatingRemainder, visitFloatLiteral, visitGreaterThan, visitGreaterThanOrEqual, visitImplicitThis, visitIntegerDivision, visitIntegerLiteral, visitIntegerRemainder, visitLeftShift, visitLessThan, visitLessThanOrEqual, visitLongLiteral, visitMarker, visitMemberReference, visitMethodAccess, visitNullChk, visitNullLiteral, visitNumericalAddition, visitNumericalMinus, visitNumericalMultiplication, visitNumericalPlus, visitNumericalSubtraction, visitPackageName, visitParameterizedType, visitPrimitiveType, visitShortLiteral, visitSignedRightShift, visitStringConcatenate, visitStringLiteral, visitSuper, visitSynchronized, visitThrow, visitTypeCast, visitUnsignedRightShift
-
Field Details
-
javaLangExceptionType
The type mirror forException
.
-
-
Constructor Details
-
CalledMethodsTransfer
Create a new CalledMethodsTransfer.- Parameters:
analysis
- the analysis
-
-
Method Details
-
shouldPerformWholeProgramInference
Description copied from class:CFAbstractTransfer
Returns true if whole-program inference should be performed. If the tree is in the scope of a @SuppressWarnings, then this method returns false.- Overrides:
shouldPerformWholeProgramInference
in classCFAbstractTransfer<AccumulationValue,
AccumulationStore, AccumulationTransfer> - Parameters:
tree
- a tree- Returns:
- false if Resource Leak Checker is running as one of the upstream checkers and the
-AenableWpiForRlc flag (see
ResourceLeakChecker.ENABLE_WPI_FOR_RLC
) is not passed as a command line argument, otherwise returns the result of the super call
-
shouldPerformWholeProgramInference
- Overrides:
shouldPerformWholeProgramInference
in classCFAbstractTransfer<AccumulationValue,
AccumulationStore, AccumulationTransfer> - Parameters:
expressionTree
- a treelhsTree
- its element- Returns:
- false if Resource Leak Checker is running as one of the upstream checkers and the -AenableWpiForRlc flag is not passed as a command line argument, otherwise returns the result of the super call
-
visitMethodInvocation
public TransferResult<AccumulationValue,AccumulationStore> visitMethodInvocation(MethodInvocationNode node, TransferInput<AccumulationValue, AccumulationStore> input) - Specified by:
visitMethodInvocation
in interfaceNodeVisitor<TransferResult<AccumulationValue,
AccumulationStore>, TransferInput<AccumulationValue, AccumulationStore>> - Overrides:
visitMethodInvocation
in classCFAbstractTransfer<AccumulationValue,
AccumulationStore, AccumulationTransfer>
-
accumulate
public void accumulate(Node node, TransferResult<AccumulationValue, AccumulationStore> result, String... values) Description copied from class:AccumulationTransfer
Updates the estimate of how many thingsnode
has accumulated.If the node is an invocation of a method that returns its receiver, then its receiver's type will also be updated. In a chain of method calls, this process will continue backward as long as each receiver is itself a receiver-returning method invocation.
For example, suppose
node
is the expressiona.b().c()
, the new value (added by the accumulation analysis because of the.c()
call) is "foo", and b and c return their receiver. This method will directly update the estimate ofa.b().c()
to include "foo". In addition, the estimates for the expressionsa.b()
anda
would have their estimates updated to include "foo", because c and b (respectively) return their receivers. Note that due to what kind of values can be held in the store, this information is lost outside the method chain. That is, the returns-receiver propagated information is lost outside the expression in which the returns-receiver method invocations are nested.As a concrete example, consider the Called Methods accumulation checker: if
build
requires a, b, and c to be called, thenfoo.a().b().c().build();
will typecheck (they are in one fluent method chain), butfoo.a().b().c(); foo.build();
will not -- the store does not keep the information that a, b, and c have been called outside the chain.foo
's type will beCalledMethods("a")
, because onlya()
was called directly onfoo
. For such code to typecheck, the Called Methods accumulation checker uses an additional rule: the return type of a receiver-returning methodrr()
isCalledMethods("rr")
. This rule is implemented directly in theTreeAnnotator
subclass defined in the Called Methods type factory.- Overrides:
accumulate
in classAccumulationTransfer
- Parameters:
node
- the node whose estimate should be expandedresult
- the transfer result containing the store to be modifiedvalues
- the new accumulation values
-
isWpiEnabledForRLC
protected boolean isWpiEnabledForRLC()Checks if WPI is enabled for the Resource Leak Checker inference. SeeResourceLeakChecker.ENABLE_WPI_FOR_RLC
.- Returns:
- returns true if WPI is enabled for the Resource Leak Checker
-