Class MustCallInference
@Owning on owning fields and parameters, @NotOwning on return types, @EnsuresCalledMethods on methods, @MustCallAlias on parameters and return types, and @InheritableMustCall on class
declarations.
Each instance of this class corresponds to a single control flow graph (CFG), typically
representing a method. The entry method of this class is runMustCallInference(RLCCalledMethodsAnnotatedTypeFactory, ControlFlowGraph, MustCallConsistencyAnalyzer), invoked from the RLCCalledMethodsAnnotatedTypeFactory.postAnalyze(org.checkerframework.dataflow.cfg.ControlFlowGraph) method when Whole Program Inference is enabled.
The algorithm determines if the @MustCall obligation of a field is satisfied along some path leading to the regular exit point of the method. If the obligation is satisfied, the algorithm adds an @Owning annotation on the field and an @EnsuresCalledMethods annotation on the method being analyzed. Additionally, if the method being analyzed satisfies the must-call obligation of all the enclosed owning fields, the algorithm adds a @InheritableMustCall annotation on the enclosing class.
Note: This class makes the assumption that the must-call set has only one element. Must-call sets with more than one element may be supported in the future.
See ResourceLeakChecker.ENABLE_WPI_FOR_RLC for an explanation of the meaning of the
flags -Ainfer and -AenableWpiForRlc.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final AnnotationMirrorTheMustCallAliasannotation.protected final AnnotationMirrorTheNotOwningannotation.protected final AnnotationMirrorTheOwningannotation. -
Method Summary
Modifier and TypeMethodDescriptionstatic voidrunMustCallInference(RLCCalledMethodsAnnotatedTypeFactory resourceLeakAtf, ControlFlowGraph cfg, MustCallConsistencyAnalyzer mcca) Creates a MustCallInference instance and runs the inference algorithm.
-
Field Details
-
OWNING
TheOwningannotation. -
NOTOWNING
TheNotOwningannotation. -
MUSTCALLALIAS
TheMustCallAliasannotation.
-
-
Method Details
-
runMustCallInference
public static void runMustCallInference(RLCCalledMethodsAnnotatedTypeFactory resourceLeakAtf, ControlFlowGraph cfg, MustCallConsistencyAnalyzer mcca) Creates a MustCallInference instance and runs the inference algorithm. This method is called by theRLCCalledMethodsAnnotatedTypeFactory.postAnalyze(org.checkerframework.dataflow.cfg.ControlFlowGraph)method if Whole Program Inference is enabled.- Parameters:
resourceLeakAtf- the type factorycfg- the control flow graph of the method to checkmcca- the MustCallConsistencyAnalyzer
-