Class SignednessAnnotatedTypeFactory
- All Implemented Interfaces:
AnnotationProvider
- See the Checker Framework Manual:
- Signedness Checker
-
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.ParameterizedExecutableType -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final AnnotationMirrorThe @PolySigned annotation.protected final AnnotationMirrorThe @Signed annotation.protected final AnnotationMirrorThe @SignedPositiveFromUnsigned annotation.protected final AnnotationMirrorThe @SignednessBottom annotation.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, checker, currentFileAjavaTypes, elements, ensuresQualifierExpressionElement, ensuresQualifierIfExpressionElement, ensuresQualifierIfListTM, ensuresQualifierIfListValueElement, ensuresQualifierIfResultElement, ensuresQualifierIfTM, ensuresQualifierListTM, ensuresQualifierListValueElement, ensuresQualifierTM, fieldInvariantFieldElement, fieldInvariantQualifierElement, fromExpressionTreeCache, fromMemberTreeCache, fromTypeTreeCache, hasQualifierParameterValueElement, ignoreUninferredTypeArguments, loader, methodValClassNameElement, methodValMethodNameElement, methodValParamsElement, noQualifierParameterValueElement, objectGetClass, processingEnv, qualHierarchy, qualifierUpperBounds, reflectionResolver, requiresQualifierExpressionElement, requiresQualifierListTM, requiresQualifierListValueElement, requiresQualifierTM, root, shouldCache, stubTypes, trees, typeArgumentInference, typeFormatter, typeHierarchy, types, typeVarSubstitutor, uid, wpiOutputFormat -
Constructor Summary
ConstructorsConstructorDescriptionCreate a SignednessAnnotatedTypeFactory. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidadaptGetClassReturnTypeToReceiver(AnnotatedTypeMirror.AnnotatedExecutableType getClassType, AnnotatedTypeMirror receiverType, ExpressionTree tree) Java special-cases the return type ofgetClass().protected voidaddAnnotationsFromDefaultForType(@Nullable Element element, AnnotatedTypeMirror type) Adds default qualifiers based on the underlying type oftypetotype.protected voidaddComputedTypeAnnotations(Tree tree, AnnotatedTypeMirror type, boolean iUseFlow) Returns the annotations that should appear on the given irrelevant Java type.protected QualifierPolymorphismCreates theQualifierPolymorphisminstance which supports the QualifierPolymorphism mechanism.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.getAnnotatedTypeLhs(Tree lhsTree) Returns the type of a left-hand side of an assignment.getNarrowedAnnotations(AnnotationMirrorSet annos, TypeKind typeKind, TypeKind narrowedTypeKind) Returns annotations applicable to typenarrowedTypeKind, that are copied or adapted fromannos.getWidenedAnnotations(AnnotationMirrorSet annos, TypeKind typeKind, TypeKind widenedTypeKind) Returns annotations applicable to typewidenedTypeKind, that are copied or adapted fromannos.booleanReturns true iftype's underlying type might be integral: it is a number, char, or a supertype of them.Methods inherited from class org.checkerframework.common.basetype.BaseAnnotatedTypeFactory
createFlowAnalysisMethods inherited from class org.checkerframework.framework.type.GenericAnnotatedTypeFactory
addCheckedCodeDefaults, addCheckedStandardDefaults, addComputedTypeAnnotations, addComputedTypeAnnotations, addComputedTypeAnnotationsForWarnRedundant, addDefaultAnnotations, addSharedCFGForTree, addUncheckedStandardDefaults, analyze, applyInferredAnnotations, applyQualifierParameterDefaults, applyQualifierParameterDefaults, checkAndPerformFlowAnalysis, checkForDefaultQualifierInHierarchy, constructorFromUse, constructorFromUsePreSubstitution, createAndInitQualifierDefaults, createCFGVisualizer, createContractsFromMethod, createDefaultForTypeAnnotator, createDefaultForUseTypeAnnotator, createDependentTypesHelper, createFlowTransferFunction, createQualifierDefaults, createRequiresOrEnsuresQualifier, createTypeAnnotator, 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, getResultingTypeOfConstructorMemberReference, getReturnStatementStores, getSharedCFGForTree, getShouldDefaultTypeVarLocals, getSortedQualifierNames, getStoreAfter, getStoreAfter, getStoreAfter, getStoreBefore, getStoreBefore, getStoreBefore, getSupportedMonotonicTypeQualifiers, getTypeFactoryOfSubchecker, getTypeFactoryOfSubcheckerOrNull, handleCFGViz, irrelevantExtraMessage, isRelevant, isRelevant, isRelevantImpl, methodFromUse, methodFromUsePreSubstitution, parseJavaExpressionString, performFlowAnalysis, postAnalyze, postAsMemberOf, postDirectSuperTypes, postInit, preProcessClassTree, setRoot, typeVariablesFromUseMethods inherited from class org.checkerframework.framework.type.AnnotatedTypeFactory
addAliasedDeclAnnotation, addAliasedTypeAnnotation, addAliasedTypeAnnotation, addAliasedTypeAnnotation, addAliasedTypeAnnotation, addAnnotationFromFieldInvariant, addInheritedAnnotation, applyCaptureConversion, applyCaptureConversion, applyUnboxing, areSameByClass, binaryTreeArgTypes, binaryTreeArgTypes, canonicalAnnotation, checkInvalidOptionsInferSignatures, compoundAssignmentTreeArgTypes, containsSameByClass, containsUninferredTypeArguments, createAnnotatedTypeFormatter, createAnnotationClassLoader, createAnnotationFormatter, createQualifierHierarchy, createQualifierUpperBounds, createTypeArgumentInference, createTypeHierarchy, createTypeVariableSubstitutor, declarationFromElement, doesAnnotatedForApplyToThisChecker, fromElement, fromElement, fromElement, fromNewClass, getAnnotatedNullType, getAnnotatedType, getAnnotatedType, getAnnotatedType, getAnnotatedType, getAnnotatedType, getAnnotatedType, getAnnotatedType, getAnnotatedType, getAnnotatedType, getAnnotatedTypeFormatter, getAnnotatedTypeFromTypeTree, getAnnotationByClass, getAnnotationFormatter, getAnnotationMirror, getAnnotationWithMetaAnnotation, getBoxedType, getBundledTypeQualifiers, getCacheSize, getChecker, getCheckerNames, getContractExpressions, getContractListValues, getCurrentClassTree, getCurrentMethodReceiver, getDeclAnnotation, getDeclAnnotationNoAliases, getDeclAnnotations, getDeclAnnotationWithMetaAnnotation, getDefaultTypeDeclarationBounds, getDummyAssignedTo, getElementUtils, getEnclosingClassOrMethod, getEnclosingElementForArtificialTree, getEnclosingSubType, getEnclosingType, getExpressionAndOffset, getFieldInvariantAnnotationTree, getFieldInvariantDeclarationAnnotations, getFieldInvariants, getFnInterfaceFromTree, getFunctionTypeFromTree, getFunctionTypeFromTree, getImplicitReceiverType, getIterableElementType, getIterableElementType, getMethodReturnType, getNarrowedPrimitive, getPath, getProcessingEnv, getQualifierHierarchy, getQualifierParameterHierarchies, getQualifierParameterHierarchies, getQualifierUpperBounds, getReceiverType, getSelfType, getStringType, getSupportedTypeQualifierNames, getSupportedTypeQualifiers, getTreeUtils, getTypeArgumentInference, getTypeDeclarationBounds, getTypeHierarchy, getTypeOfExtendsImplements, getTypeVarSubstitutor, getUnboxedType, getUninferredWildcardType, getVisitorTreePath, getWholeProgramInference, getWidenedType, getWidenedType, hasExplicitNoQualifierParameterInHierarchy, hasExplicitQualifierParameterInHierarchy, hasQualifierParameterInHierarchy, hasQualifierParameterInHierarchy, initializeReflectionResolution, isFromByteCode, isFromStubFile, isImmutable, isSideEffectFree, isSupportedQualifier, isSupportedQualifier, isSupportedQualifier, isWithinConstructor, logGat, makeConditionConsistentWithOtherMethod, mergeAnnotationFileAnnosIntoType, methodFromUse, negateConstant, order, parseAnnotationFiles, postProcessClassTree, replaceAnnotations, replaceAnnotations, setEnclosingElementForArtificialTree, setVisitorTreePath, shouldWarnIfStubRedundantWithBytecode, toAnnotatedType, toString, type, wpiAdjustForUpdateField, wpiAdjustForUpdateNonField, wpiPrepareMethodForWriting, wpiPrepareMethodForWriting, wpiShouldInferTypesForReceivers
-
Field Details
-
SIGNED
The @Signed annotation. -
SIGNED_POSITIVE_FROM_UNSIGNED
The @SignedPositiveFromUnsigned annotation. -
SIGNEDNESS_BOTTOM
The @SignednessBottom annotation. -
POLY_SIGNED
The @PolySigned annotation.
-
-
Constructor Details
-
SignednessAnnotatedTypeFactory
Create a SignednessAnnotatedTypeFactory.- Parameters:
checker- the type-checker associated with this type factory
-
-
Method Details
-
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:
-
addComputedTypeAnnotations
Description copied from class:GenericAnnotatedTypeFactoryLikeGenericAnnotatedTypeFactory.addComputedTypeAnnotations(Tree, AnnotatedTypeMirror). Overriding implementations typically simply pass the boolean to calls to super.- Overrides:
addComputedTypeAnnotationsin classGenericAnnotatedTypeFactory<CFValue,CFStore, CFTransfer, CFAnalysis> - Parameters:
tree- an AST nodetype- the type obtained from treeiUseFlow- whether to use information from dataflow analysis
-
getAnnotatedTypeLhs
Description copied from class:GenericAnnotatedTypeFactoryReturns the type of a left-hand side of an assignment.The default implementation returns the type without considering dataflow type refinement. Subclass can override this method and add additional logic for computing the type of a LHS.
- Overrides:
getAnnotatedTypeLhsin classGenericAnnotatedTypeFactory<CFValue,CFStore, CFTransfer, CFAnalysis> - Parameters:
lhsTree- left-hand side of an assignment- Returns:
- AnnotatedTypeMirror of
lhsTree
-
getWidenedAnnotations
public AnnotationMirrorSet getWidenedAnnotations(AnnotationMirrorSet annos, TypeKind typeKind, TypeKind widenedTypeKind) Description copied from class:AnnotatedTypeFactoryReturns annotations applicable to typewidenedTypeKind, that are copied or adapted fromannos.- Overrides:
getWidenedAnnotationsin classAnnotatedTypeFactory- Parameters:
annos- annotations to widen, from a primitive or boxed primitivetypeKind- primitive type to widenwidenedTypeKind- target for the returned annotations; a primitive type that is wider thantypeKind(in the sense of JLS 5.1.2)- Returns:
- result of converting
annosfromtypeKindtowidenedTypeKind
-
getNarrowedAnnotations
public AnnotationMirrorSet getNarrowedAnnotations(AnnotationMirrorSet annos, TypeKind typeKind, TypeKind narrowedTypeKind) Description copied from class:AnnotatedTypeFactoryReturns annotations applicable to typenarrowedTypeKind, that are copied or adapted fromannos.- Overrides:
getNarrowedAnnotationsin classAnnotatedTypeFactory- Parameters:
annos- annotations to narrow, from a primitive or boxed primitivetypeKind- primitive type to narrownarrowedTypeKind- target for the returned annotations; a primitive type that is narrower thantypeKind(in the sense of JLS 5.1.3).- Returns:
- result of converting
annosfromtypeKindtonarrowedTypeKind
-
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
-
annotationsForIrrelevantJavaType
Description copied from class:GenericAnnotatedTypeFactoryReturns the annotations that should appear on the given irrelevant Java type. If the type is relevant, this method's behavior is undefined.- Overrides:
annotationsForIrrelevantJavaTypein classGenericAnnotatedTypeFactory<CFValue,CFStore, CFTransfer, CFAnalysis> - Parameters:
tm- an irrelevant Java type- Returns:
- the annotations that should appear on the given irrelevant Java type
-
maybeIntegral
Returns true iftype's underlying type might be integral: it is a number, char, or a supertype of them.- Parameters:
type- a type- Returns:
- true if
type's underlying type might be integral
-
adaptGetClassReturnTypeToReceiver
protected void adaptGetClassReturnTypeToReceiver(AnnotatedTypeMirror.AnnotatedExecutableType getClassType, AnnotatedTypeMirror receiverType, ExpressionTree tree) Description copied from class:AnnotatedTypeFactoryJava special-cases the return type ofgetClass(). Though the method has a return type ofClass<?>, the compiler special cases this return-type and changes the bound of the type argument to the erasure of the receiver type. For example:x.getClass()has the typeClass< ? extends erasure_of_x >someInteger.getClass()has the typeClass< ? extends Integer >
- Overrides:
adaptGetClassReturnTypeToReceiverin classAnnotatedTypeFactory- Parameters:
getClassType- this must be a type representing a call to Object.getClass otherwise a runtime exception will be thrown. It is modified by side effect.receiverType- the receiver type of the method invocation (not the declared receiver type)tree- getClass method invocation tree
-
addAnnotationsFromDefaultForType
protected void addAnnotationsFromDefaultForType(@Nullable Element element, AnnotatedTypeMirror type) Description copied from class:GenericAnnotatedTypeFactoryAdds default qualifiers based on the underlying type oftypetotype. Ifelementis a local variable, or if the type already has an annotation from the relevant type hierarchy, then the defaults are not added.(This uses both the
DefaultQualifierForUseTypeAnnotatorandDefaultForTypeAnnotator.)- Overrides:
addAnnotationsFromDefaultForTypein classGenericAnnotatedTypeFactory<CFValue,CFStore, CFTransfer, CFAnalysis> - Parameters:
element- possibly null element whose type istypetype- the type to which defaults are added
-
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
-