Class SignednessAnnotatedTypeFactory
java.lang.Object
org.checkerframework.framework.type.AnnotatedTypeFactory
org.checkerframework.framework.type.GenericAnnotatedTypeFactory<CFValue,CFStore,CFTransfer,CFAnalysis>
org.checkerframework.common.basetype.BaseAnnotatedTypeFactory
org.checkerframework.checker.signedness.SignednessAnnotatedTypeFactory
- All Implemented Interfaces:
AnnotationProvider
The type factory for the Signedness Checker.
- See the Checker Framework Manual:
- Signedness Checker
-
Nested Class Summary
Nested classes/interfaces inherited from class org.checkerframework.framework.type.GenericAnnotatedTypeFactory
GenericAnnotatedTypeFactory.ScanState
Nested classes/interfaces inherited from class org.checkerframework.framework.type.AnnotatedTypeFactory
AnnotatedTypeFactory.CapturedTypeVarSubstitutor, AnnotatedTypeFactory.ParameterizedExecutableType
-
Field Summary
Modifier and TypeFieldDescriptionprotected final AnnotationMirror
The @PolySigned annotation.protected final AnnotationMirror
The @Signed annotation.protected final AnnotationMirror
The @SignedPositive annotation.protected final AnnotationMirror
The @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, typeAnnotator
Fields 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, types, typeVarSubstitutor, uid, wpiOutputFormat
-
Constructor Summary
ConstructorDescriptionCreate a SignednessAnnotatedTypeFactory. -
Method Summary
Modifier and TypeMethodDescriptionprotected void
adaptGetClassReturnTypeToReceiver
(AnnotatedTypeMirror.AnnotatedExecutableType getClassType, AnnotatedTypeMirror receiverType, ExpressionTree tree) Java special-cases the return type ofgetClass()
.protected void
addAnnotationsFromDefaultForType
(@Nullable Element element, AnnotatedTypeMirror type) Adds default qualifiers based on the underlying type oftype
totype
.protected void
addComputedTypeAnnotations
(Tree tree, AnnotatedTypeMirror type, boolean iUseFlow) Returns the annotations that should appear on the given irrelevant Java type.protected QualifierPolymorphism
Creates theQualifierPolymorphism
instance which supports the QualifierPolymorphism mechanism.protected TreeAnnotator
Returns aTreeAnnotator
that 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
.boolean
Returns 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
createFlowAnalysis
Methods 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, getReturnStatementStores, getSharedCFGForTree, getShouldDefaultTypeVarLocals, getSortedQualifierNames, getStoreAfter, getStoreAfter, getStoreAfter, getStoreBefore, getStoreBefore, getStoreBefore, getSupportedMonotonicTypeQualifiers, getTypeFactoryOfSubchecker, getTypeFactoryOfSubcheckerOrNull, handleCFGViz, irrelevantExtraMessage, isIgnoredExceptionType, isRelevant, isRelevant, isRelevantImpl, isUnreachable, methodFromUse, methodFromUsePreSubstitution, parseJavaExpressionString, performFlowAnalysis, postAnalyze, postAsMemberOf, postDirectSuperTypes, postInit, preProcessClassTree, setRoot, typeVariablesFromUse
Methods inherited from class org.checkerframework.framework.type.AnnotatedTypeFactory
addAliasedDeclAnnotation, addAliasedTypeAnnotation, addAliasedTypeAnnotation, addAliasedTypeAnnotation, addAliasedTypeAnnotation, addAnnotationFromFieldInvariant, addInheritedAnnotation, applyCaptureConversion, applyCaptureConversion, applyUnboxing, areSameByClass, binaryTreeArgTypes, binaryTreeArgTypes, canonicalAnnotation, checkInvalidOptionsInferSignatures, compoundAssignmentTreeArgTypes, constructorFromUse, constructorFromUseWithoutTypeArgInference, containsCapturedTypes, containsSameByClass, createAnnotatedTypeFormatter, createAnnotationClassLoader, createAnnotationFormatter, createQualifierHierarchy, createQualifierUpperBounds, createSupportedTypeQualifiers, createTypeArgumentInference, createTypeHierarchy, 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, getNarrowedPrimitive, getPath, getProcessingEnv, getQualifierHierarchy, getQualifierParameterHierarchies, getQualifierParameterHierarchies, getQualifierUpperBounds, getReceiverType, getResultingTypeOfConstructorMemberReference, getSelfType, getStringType, getSupportedTypeQualifierNames, getSupportedTypeQualifiers, getTreeUtils, getTypeArgumentInference, getTypeDeclarationBounds, getTypeHierarchy, getTypeOfExtendsImplements, getTypeVarSubstitutor, getUnboxedType, getVisitorTreePath, getWholeProgramInference, 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
-
SIGNED
The @Signed annotation. -
SIGNED_POSITIVE
The @SignedPositive 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
-
addComputedTypeAnnotations
Description copied from class:GenericAnnotatedTypeFactory
LikeGenericAnnotatedTypeFactory.addComputedTypeAnnotations(Tree, AnnotatedTypeMirror)
. Overriding implementations typically simply pass the boolean to calls to super.- Overrides:
addComputedTypeAnnotations
in 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:GenericAnnotatedTypeFactory
Returns 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:
getAnnotatedTypeLhs
in 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:AnnotatedTypeFactory
Returns annotations applicable to typewidenedTypeKind
, that are copied or adapted fromannos
.- Overrides:
getWidenedAnnotations
in 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
annos
fromtypeKind
towidenedTypeKind
-
getNarrowedAnnotations
public AnnotationMirrorSet getNarrowedAnnotations(AnnotationMirrorSet annos, TypeKind typeKind, TypeKind narrowedTypeKind) Description copied from class:AnnotatedTypeFactory
Returns annotations applicable to typenarrowedTypeKind
, that are copied or adapted fromannos
.- Overrides:
getNarrowedAnnotations
in 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
annos
fromtypeKind
tonarrowedTypeKind
-
createTreeAnnotator
Description copied from class:GenericAnnotatedTypeFactory
Returns aTreeAnnotator
that adds annotations to a type based on the contents of a tree.The default tree annotator is a
ListTreeAnnotator
of the following:PropagationTreeAnnotator
: Propagates annotations from subtreesLiteralTreeAnnotator
: Adds annotations based onQualifierForLiterals
meta-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:
createTreeAnnotator
in classGenericAnnotatedTypeFactory<CFValue,
CFStore, CFTransfer, CFAnalysis> - Returns:
- a tree annotator
-
annotationsForIrrelevantJavaType
Description copied from class:GenericAnnotatedTypeFactory
Returns the annotations that should appear on the given irrelevant Java type. If the type is relevant, this method's behavior is undefined.- Overrides:
annotationsForIrrelevantJavaType
in 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:AnnotatedTypeFactory
Java 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:
adaptGetClassReturnTypeToReceiver
in 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:GenericAnnotatedTypeFactory
Adds default qualifiers based on the underlying type oftype
totype
. Ifelement
is 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
DefaultQualifierForUseTypeAnnotator
andDefaultForTypeAnnotator
.)- Overrides:
addAnnotationsFromDefaultForType
in classGenericAnnotatedTypeFactory<CFValue,
CFStore, CFTransfer, CFAnalysis> - Parameters:
element
- possibly null element whose type istype
type
- the type to which defaults are added
-
createQualifierPolymorphism
Description copied from class:GenericAnnotatedTypeFactory
Creates theQualifierPolymorphism
instance which supports the QualifierPolymorphism mechanism.- Overrides:
createQualifierPolymorphism
in classGenericAnnotatedTypeFactory<CFValue,
CFStore, CFTransfer, CFAnalysis> - Returns:
- the QualifierPolymorphism instance to use
-