Class MustCallAnnotatedTypeFactory
- All Implemented Interfaces:
CreatesMustCallForElementSupplier,AnnotationProvider
-
Nested Class Summary
Nested classes/interfaces inherited from class org.checkerframework.framework.type.GenericAnnotatedTypeFactory
GenericAnnotatedTypeFactory.ScanStateNested classes/interfaces inherited from class org.checkerframework.framework.type.AnnotatedTypeFactory
AnnotatedTypeFactory.CapturedTypeVarSubstitutor, AnnotatedTypeFactory.ParameterizedExecutableType -
Field Summary
FieldsModifier and TypeFieldDescriptionfinal AnnotationMirrorfinal AnnotationMirrorThe@PolyMustCallannotation.final AnnotationMirrorThe@MustCallUnknownannotation.Fields inherited from class org.checkerframework.framework.type.GenericAnnotatedTypeFactory
analysis, arraysAreRelevant, cfgVisualizer, contractsUtils, defaults, dependentTypesHelper, emptyStore, exceptionalExitStores, flowByDefault, flowResult, flowResultAnalysisCaches, formalParameterPattern, hasOrIsSubchecker, initializationStaticStore, initializationStore, methodInvocationStores, poly, regularExitStores, relevantJavaTypes, returnStatementStores, scannedClasses, shouldClearSubcheckerSharedCFGs, sideEffectsUnrefineAliases, subcheckerSharedCFG, transfer, treeAnnotator, typeAnnotatorFields inherited from class org.checkerframework.framework.type.AnnotatedTypeFactory
ajavaTypes, annotatedForValueElement, artificialTreeToEnclosingElementMap, capturedTypeVarSubstitutor, checker, currentFileAjavaTypes, elements, ensuresQualifierExpressionElement, ensuresQualifierIfExpressionElement, ensuresQualifierIfListTM, ensuresQualifierIfListValueElement, ensuresQualifierIfResultElement, ensuresQualifierIfTM, ensuresQualifierListTM, ensuresQualifierListValueElement, ensuresQualifierTM, fieldInvariantFieldElement, fieldInvariantQualifierElement, fromExpressionTreeCache, fromMemberTreeCache, fromTypeTreeCache, hasQualifierParameterValueElement, ignoreRawTypeArguments, loader, methodValClassNameElement, methodValMethodNameElement, methodValParamsElement, noQualifierParameterValueElement, objectGetClass, processingEnv, qualHierarchy, qualifierUpperBounds, reflectionResolver, requiresQualifierExpressionElement, requiresQualifierListTM, requiresQualifierListValueElement, requiresQualifierTM, root, shouldCache, stubTypes, trees, typeArgumentInference, typeFormatter, typeHierarchy, typeInformationPresenter, types, typeVarSubstitutor, uid, wpiOutputFormat -
Constructor Summary
ConstructorsConstructorDescriptionCreates a MustCallAnnotatedTypeFactory. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidconstructorFromUsePreSubstitution(NewClassTree tree, AnnotatedTypeMirror.AnnotatedExecutableType type, boolean resolvePolyQuals) A callback method for the AnnotatedTypeFactory subtypes to customize the handling of the declared constructor type before type variable substitution.protected DefaultQualifierForUseTypeAnnotatorCreates anDefaultQualifierForUseTypeAnnotator.createMustCall(List<String> val) Creates aMustCallannotation whose values are the given strings.protected QualifierHierarchyReturns theQualifierHierarchyto be used by this checker.protected QualifierPolymorphismCreates theQualifierPolymorphisminstance which supports the QualifierPolymorphism mechanism.protected QualifierUpperBoundsCreatesQualifierUpperBoundsfor this type factory.protected Set<Class<? extends Annotation>> Returns a mutable set of annotation classes that are supported by a checker.protected TreeAnnotatorReturns aTreeAnnotatorthat adds annotations to a type based on the contents of a tree.protected TypeAnnotatorReturns aDefaultForTypeAnnotatorthat adds annotations to a type based on the content of the type itself.Returns the CreatesMustCallFor.List.value field/element.Returns the CreatesMustCallFor.value field/element.Returns theInheritableMustCall.value()element.Returns theMustCall.value()element.getStoreForBlock(boolean afterFirstStore, Block first, Block succ) Fetches the store from the results of dataflow forfirst.getTempVar(Node node) Return the temporary variable for node, if it exists.protected booleanChecks if WPI is enabled for the Resource Leak Checker inference.voidmethodFromUsePreSubstitution(ExpressionTree tree, AnnotatedTypeMirror.AnnotatedExecutableType type, boolean resolvePolyQuals) Treat non-owning method parameters as @MustCallUnknown (top) when the method is called.voidsetRoot(@Nullable CompilationUnitTree newRoot) Set the CompilationUnitTree that should be used.booleanReturns true if the given type should never have a must-call obligation.Returns a @MustCall annotation that is like the input, but it does not have "close".Methods inherited from class org.checkerframework.common.basetype.BaseAnnotatedTypeFactory
createFlowAnalysisMethods inherited from class org.checkerframework.framework.type.GenericAnnotatedTypeFactory
addAnnotationsFromDefaultForType, addCheckedCodeDefaults, addCheckedStandardDefaults, addComputedTypeAnnotations, addComputedTypeAnnotations, addComputedTypeAnnotations, addComputedTypeAnnotationsForWarnRedundant, addDefaultAnnotations, addSharedCFGForTree, addUncheckedStandardDefaults, analyze, annotationsForIrrelevantJavaType, applyInferredAnnotations, applyQualifierParameterDefaults, applyQualifierParameterDefaults, checkAndPerformFlowAnalysis, checkForDefaultQualifierInHierarchy, constructorFromUse, createAndInitQualifierDefaults, createCFGVisualizer, createContractsFromMethod, createDefaultForTypeAnnotator, createDependentTypesHelper, createFlowTransferFunction, createQualifierDefaults, createRequiresOrEnsuresQualifier, getAnnotatedTypeLhs, getAnnotatedTypeLhsNoTypeVarDefault, getAnnotatedTypeRhsUnaryAssign, getAnnotatedTypeVarargsArray, getAnnotationFromJavaExpression, getAnnotationFromJavaExpressionString, getAnnotationMirrorFromJavaExpressionString, getAnnotationsFromJavaExpression, getCFGVisualizer, getContractAnnotations, getContractAnnotations, getContractExpressions, getContractsFromMethod, getDefaultAnnotations, getDefaultAnnotationsForWarnRedundant, getDefaultForTypeAnnotator, getDefaultValueAnnotatedType, getDependentTypesHelper, getEmptyStore, getEnsuresQualifierIfResult, getExceptionalExitStore, getExplicitNewClassAnnos, getExplicitNewClassClassTypeArgs, getExpressionAndOffsetFromJavaExpressionString, getFinalLocalValues, getFirstNodeOfKindForTree, getInferredValueFor, getMethodReturnType, getNodesForTree, getPostconditionAnnotations, getPostconditionAnnotations, getPostconditionAnnotations, getPreconditionAnnotations, getPreconditionAnnotations, getPreconditionAnnotations, getPreOrPostconditionAnnotations, getQualifierPolymorphism, getRegularExitStore, getReturnStatementStores, getSharedCFGForTree, getShouldDefaultTypeVarLocals, getSortedQualifierNames, getStoreAfter, getStoreAfter, getStoreAfter, getStoreBefore, getStoreBefore, getStoreBefore, getSupportedMonotonicTypeQualifiers, getTypeFactoryOfSubchecker, getTypeFactoryOfSubcheckerOrNull, handleCFGViz, irrelevantExtraMessage, isIgnoredExceptionType, isRelevant, isRelevant, isRelevantImpl, isUnreachable, methodFromUse, parseJavaExpressionString, performFlowAnalysis, postAnalyze, postAsMemberOf, postDirectSuperTypes, postInit, preProcessClassTree, typeVariablesFromUseMethods inherited from class org.checkerframework.framework.type.AnnotatedTypeFactory
adaptGetClassReturnTypeToReceiver, addAliasedDeclAnnotation, addAliasedTypeAnnotation, addAliasedTypeAnnotation, addAliasedTypeAnnotation, addAliasedTypeAnnotation, addAnnotationFromFieldInvariant, addInheritedAnnotation, applyCaptureConversion, applyCaptureConversion, applyUnboxing, areSameByClass, binaryTreeArgTypes, binaryTreeArgTypes, canonicalAnnotation, checkInvalidOptionsInferSignatures, compoundAssignmentTreeArgTypes, constructorFromUse, constructorFromUseWithoutTypeArgInference, containsCapturedTypes, containsSameByClass, createAnnotatedTypeFormatter, createAnnotationClassLoader, createAnnotationFormatter, createTypeArgumentInference, createTypeHierarchy, createTypeInformationPresenter, createTypeVariableSubstitutor, declarationFromElement, doesAnnotatedForApplyToThisChecker, fromElement, fromElement, fromElement, getAnnotatedNullType, getAnnotatedType, getAnnotatedType, getAnnotatedType, getAnnotatedType, getAnnotatedType, getAnnotatedType, getAnnotatedType, getAnnotatedType, getAnnotatedType, getAnnotatedTypeFormatter, getAnnotatedTypeFromTypeTree, getAnnotationByClass, getAnnotationFormatter, getAnnotationMirror, getAnnotationWithMetaAnnotation, getBoxedType, getBundledTypeQualifiers, getCacheSize, getChecker, getCheckerNames, getContractExpressions, getContractListValues, getDeclAnnotation, getDeclAnnotationNoAliases, getDeclAnnotations, getDeclAnnotationWithMetaAnnotation, getDefaultTypeDeclarationBounds, getDummyAssignedTo, getElementUtils, getEnclosingClassOrMethod, getEnclosingElementForArtificialTree, getEnclosingSubType, getEnclosingType, getEnumConstructorQualifiers, getExpressionAndOffset, getFieldInvariantAnnotationTree, getFieldInvariantDeclarationAnnotations, getFieldInvariants, getFnInterfaceFromTree, getFunctionTypeFromTree, getFunctionTypeFromTree, getImplicitReceiverType, getIterableElementType, getIterableElementType, getMethodReturnType, getNarrowedAnnotations, getNarrowedPrimitive, getPath, getProcessingEnv, getQualifierHierarchy, getQualifierParameterHierarchies, getQualifierParameterHierarchies, getQualifierUpperBounds, getReceiverType, getResultingTypeOfConstructorMemberReference, getSelfType, getStringType, getSupportedTypeQualifierNames, getSupportedTypeQualifiers, getTreeUtils, getTypeArgumentInference, getTypeDeclarationBounds, getTypeHierarchy, getTypeOfExtendsImplements, getTypeVarSubstitutor, getUnboxedType, getVisitorTreePath, getWholeProgramInference, getWidenedAnnotations, getWidenedType, getWidenedType, hasExplicitNoQualifierParameterInHierarchy, hasExplicitQualifierParameterInHierarchy, hasQualifierParameterInHierarchy, hasQualifierParameterInHierarchy, initializeAtm, initializeReflectionResolution, isDeterministic, isFromByteCode, isFromStubFile, isImmutable, isSideEffectFree, isSupportedQualifier, isSupportedQualifier, isSupportedQualifier, isTop, isWithinConstructor, logGat, makeConditionConsistentWithOtherMethod, mergeAnnotationFileAnnosIntoType, methodFromUse, methodFromUse, methodFromUse, methodFromUseWithoutTypeArgInference, methodFromUseWithoutTypeArgInference, negateConstant, order, parseAnnotationFiles, postProcessClassTree, replaceAnnotations, replaceAnnotations, setEnclosingElementForArtificialTree, setVisitorTreePath, shouldWarnIfStubRedundantWithBytecode, toAnnotatedType, toString, type, wpiAdjustForUpdateField, wpiAdjustForUpdateNonField, wpiPrepareMethodForWriting, wpiPrepareMethodForWriting, wpiShouldInferTypesForReceivers
-
Field Details
-
TOP
The@MustCallUnknownannotation. -
BOTTOM
-
POLY
The@PolyMustCallannotation.
-
-
Constructor Details
-
MustCallAnnotatedTypeFactory
Creates a MustCallAnnotatedTypeFactory.- Parameters:
checker- the checker associated with this type factory
-
-
Method Details
-
setRoot
Description copied from class:AnnotatedTypeFactorySet the CompilationUnitTree that should be used.- Overrides:
setRootin classGenericAnnotatedTypeFactory<CFValue,CFStore, CFTransfer, CFAnalysis> - Parameters:
newRoot- the new compilation unit to use
-
createSupportedTypeQualifiers
Description copied from class:AnnotatedTypeFactoryReturns a mutable set of annotation classes that are supported by a checker.Subclasses may override this method to return a mutable set of their supported type qualifiers through one of the 5 approaches shown below.
Subclasses should not call this method; they should call
AnnotatedTypeFactory.getSupportedTypeQualifiers()instead.By default, a checker supports all annotations located in a subdirectory called qual that's located in the same directory as the checker. Note that only annotations defined with the
@Target({ElementType.TYPE_USE})meta-annotation (and optionally with the additional value ofElementType.TYPE_PARAMETER, but no otherElementTypevalues) are automatically considered as supported annotations.To support a different set of annotations than those in the qual subdirectory, or that have other
ElementTypevalues, see examples below.In total, there are 5 ways to indicate annotations that are supported by a checker:
- Only support annotations located in a checker's qual directory:
This is the default behavior. Simply place those annotations within the qual directory.
- Support annotations located in a checker's qual directory and a list of other
annotations:
Place those annotations within the qual directory, and override
AnnotatedTypeFactory.createSupportedTypeQualifiers()by callingAnnotatedTypeFactory.getBundledTypeQualifiers(Class...)with a varargs parameter list of the other annotations. Code example:@Override protected Set<Class<? extends Annotation>> createSupportedTypeQualifiers() { return getBundledTypeQualifiers(Regex.class, PartialRegex.class, RegexBottom.class, UnknownRegex.class); } - Supporting only annotations that are explicitly listed: Override
AnnotatedTypeFactory.createSupportedTypeQualifiers()and return a mutable set of the supported annotations. Code example:
The set of qualifiers returned by@Override protected Set<Class<? extends Annotation>> createSupportedTypeQualifiers() { return new HashSet<Class<? extends Annotation>>( Arrays.asList(A.class, B.class)); }AnnotatedTypeFactory.createSupportedTypeQualifiers()must be a fresh, mutable set. The methodsAnnotatedTypeFactory.getBundledTypeQualifiers(Class...)must return a fresh, mutable set
- Overrides:
createSupportedTypeQualifiersin classAnnotatedTypeFactory- Returns:
- the type qualifiers supported this processor, or an empty set if none
- Only support annotations located in a checker's qual directory:
-
createTreeAnnotator
Description copied from class:GenericAnnotatedTypeFactoryReturns aTreeAnnotatorthat adds annotations to a type based on the contents of a tree.The default tree annotator is a
ListTreeAnnotatorof the following:PropagationTreeAnnotator: Propagates annotations from subtreesLiteralTreeAnnotator: Adds annotations based onQualifierForLiteralsmeta-annotationsDependentTypesTreeAnnotator: Adapts dependent annotations based on context
Subclasses may override this method to specify additional tree annotators, for example:
new ListTreeAnnotator(super.createTreeAnnotator(), new KeyLookupTreeAnnotator(this));
- Overrides:
createTreeAnnotatorin classGenericAnnotatedTypeFactory<CFValue,CFStore, CFTransfer, CFAnalysis> - Returns:
- a tree annotator
-
createTypeAnnotator
Description copied from class:GenericAnnotatedTypeFactoryReturns aDefaultForTypeAnnotatorthat adds annotations to a type based on the content of the type itself.Subclass may override this method. The default type annotator is a
ListTypeAnnotatorof the following:IrrelevantTypeAnnotator: Adds top to types not listed in the@RelevantJavaTypesannotation on the checker.PropagationTypeAnnotator: Propagates annotation onto wildcards.
- Overrides:
createTypeAnnotatorin classGenericAnnotatedTypeFactory<CFValue,CFStore, CFTransfer, CFAnalysis> - Returns:
- a type annotator
-
withoutClose
Returns a @MustCall annotation that is like the input, but it does not have "close". Returns the argument annotation mirror (not a new one) if the argument doesn't have "close" as one of its elements.If the argument is null, returns bottom.
- Parameters:
anno- a MustCall annotation- Returns:
- a MustCall annotation that does not have "close" as one of its values, but is otherwise identical to anno
-
methodFromUsePreSubstitution
public void methodFromUsePreSubstitution(ExpressionTree tree, AnnotatedTypeMirror.AnnotatedExecutableType type, boolean resolvePolyQuals) Treat non-owning method parameters as @MustCallUnknown (top) when the method is called.- Overrides:
methodFromUsePreSubstitutionin classGenericAnnotatedTypeFactory<CFValue,CFStore, CFTransfer, CFAnalysis> - Parameters:
tree- either a method invocation or a member reference treetype- declared method type before type variable substitutionresolvePolyQuals- whether to resolve polymorphic qualifiers
-
constructorFromUsePreSubstitution
protected void constructorFromUsePreSubstitution(NewClassTree tree, AnnotatedTypeMirror.AnnotatedExecutableType type, boolean resolvePolyQuals) Description copied from class:AnnotatedTypeFactoryA callback method for the AnnotatedTypeFactory subtypes to customize the handling of the declared constructor type before type variable substitution.- Overrides:
constructorFromUsePreSubstitutionin classGenericAnnotatedTypeFactory<CFValue,CFStore, CFTransfer, CFAnalysis> - Parameters:
tree- a NewClassTree from constructorFromUse()type- declared method type before type variable substitutionresolvePolyQuals- whether to resolve polymorphic qualifiers
-
createQualifierPolymorphism
Description copied from class:GenericAnnotatedTypeFactoryCreates theQualifierPolymorphisminstance which supports the QualifierPolymorphism mechanism.- Overrides:
createQualifierPolymorphismin classGenericAnnotatedTypeFactory<CFValue,CFStore, CFTransfer, CFAnalysis> - Returns:
- the QualifierPolymorphism instance to use
-
createDefaultForUseTypeAnnotator
Description copied from class:GenericAnnotatedTypeFactoryCreates anDefaultQualifierForUseTypeAnnotator.- Overrides:
createDefaultForUseTypeAnnotatorin classGenericAnnotatedTypeFactory<CFValue,CFStore, CFTransfer, CFAnalysis> - Returns:
- a new
DefaultQualifierForUseTypeAnnotator
-
getMustCallValueElement
Returns theMustCall.value()element. For use withAnnotationUtils.getElementValueArray(javax.lang.model.element.AnnotationMirror, java.lang.CharSequence, java.lang.Class<T>, boolean).- Returns:
- the
MustCall.value()element
-
getInheritableMustCallValueElement
Returns theInheritableMustCall.value()element.- Returns:
- the
InheritableMustCall.value()element
-
createQualifierUpperBounds
Description copied from class:AnnotatedTypeFactoryCreatesQualifierUpperBoundsfor this type factory.- Overrides:
createQualifierUpperBoundsin classAnnotatedTypeFactory- Returns:
- a new
QualifierUpperBoundsfor this type factory
-
createMustCall
Creates aMustCallannotation whose values are the given strings.- Parameters:
val- the methods that should be called- Returns:
- an annotation indicating that the given methods should be called
-
createQualifierHierarchy
Description copied from class:AnnotatedTypeFactoryReturns theQualifierHierarchyto be used by this checker.The implementation builds the type qualifier hierarchy for the
AnnotatedTypeFactory.getSupportedTypeQualifiers()using the meta-annotations found in them. The current implementation returns an instance ofNoElementQualifierHierarchy.Subclasses must override this method if their qualifiers have elements; the method must return an implementation of
QualifierHierarchy, such asElementQualifierHierarchy.- Overrides:
createQualifierHierarchyin classAnnotatedTypeFactory- Returns:
- a QualifierHierarchy for this type system
-
getStoreForBlock
Fetches the store from the results of dataflow forfirst. IfafterFirstStoreis true, then the store afterfirstis returned; ifafterFirstStoreis false, the store beforesuccis returned.- Parameters:
afterFirstStore- whether to use the store after the first block or the store before its successor, succfirst- a blocksucc- first's successor- Returns:
- the appropriate CFStore, populated with MustCall annotations, from the results of running dataflow
-
getCreatesMustCallForValueElement
Returns the CreatesMustCallFor.value field/element.- Specified by:
getCreatesMustCallForValueElementin interfaceCreatesMustCallForElementSupplier- Returns:
- the CreatesMustCallFor.value field/element
-
getCreatesMustCallForListValueElement
Returns the CreatesMustCallFor.List.value field/element.- Specified by:
getCreatesMustCallForListValueElementin interfaceCreatesMustCallForElementSupplier- Returns:
- the CreatesMustCallFor.List.value field/element
-
getTempVar
Return the temporary variable for node, if it exists. See#tempVars.- Parameters:
node- a CFG node- Returns:
- the corresponding temporary variable, or null if there is not one
-
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
-
shouldHaveNoMustCallObligation
Returns true if the given type should never have a must-call obligation.- Parameters:
type- the type to check- Returns:
- true if the given type should never have a must-call obligation
-