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
public class SignednessAnnotatedTypeFactory extends BaseAnnotatedTypeFactory
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.ParameterizedExecutableType
-
-
Field Summary
Fields Modifier and Type Field Description protected javax.lang.model.element.AnnotationMirror
POLY_SIGNED
The @PolySigned annotation.protected javax.lang.model.element.AnnotationMirror
SIGNED
The @Signed annotation.protected javax.lang.model.element.AnnotationMirror
SIGNED_POSITIVE
The @SignedPositive annotation.protected javax.lang.model.element.AnnotationMirror
SIGNEDNESS_BOTTOM
The @SignednessBottom annotation.protected javax.lang.model.element.AnnotationMirror
SIGNEDNESS_GLB
The @SignednessGlb annotation.protected javax.lang.model.element.AnnotationMirror
UNSIGNED
The @Unsigned 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, poly, regularExitStores, relevantJavaTypes, returnStatementStores, scannedClasses, shouldClearSubcheckerSharedCFGs, sideEffectsUnrefineAliases, subcheckerSharedCFG, transfer, treeAnnotator, typeAnnotator
-
Fields inherited from class org.checkerframework.framework.type.AnnotatedTypeFactory
ajavaTypes, annotatedForValueElement, 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, viewpointAdapter
-
-
Constructor Summary
Constructors Constructor Description SignednessAnnotatedTypeFactory(BaseTypeChecker checker)
Create a SignednessAnnotatedTypeFactory.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
adaptGetClassReturnTypeToReceiver(AnnotatedTypeMirror.AnnotatedExecutableType getClassType, AnnotatedTypeMirror receiverType, com.sun.source.tree.ExpressionTree tree)
Java special-cases the return type ofgetClass()
.protected void
addAnnotationsFromDefaultForType(@Nullable javax.lang.model.element.Element element, AnnotatedTypeMirror type)
Adds default qualifiers based on the underlying type oftype
totype
.protected void
addComputedTypeAnnotations(com.sun.source.tree.Tree tree, AnnotatedTypeMirror type, boolean iUseFlow)
AnnotationMirrorSet
annotationsForIrrelevantJavaType(javax.lang.model.type.TypeMirror tm)
Returns the annotations that should appear on the given irrelevant Java type.protected QualifierPolymorphism
createQualifierPolymorphism()
Creates theQualifierPolymorphism
instance which supports the QualifierPolymorphism mechanism.protected TreeAnnotator
createTreeAnnotator()
Returns aTreeAnnotator
that adds annotations to a type based on the contents of a tree.AnnotationMirrorSet
getNarrowedAnnotations(AnnotationMirrorSet annos, javax.lang.model.type.TypeKind typeKind, javax.lang.model.type.TypeKind narrowedTypeKind)
Returns annotations applicable to typenarrowedTypeKind
, that are copied or adapted fromannos
.AnnotationMirrorSet
getWidenedAnnotations(AnnotationMirrorSet annos, javax.lang.model.type.TypeKind typeKind, javax.lang.model.type.TypeKind widenedTypeKind)
Returns annotations applicable to typewidenedTypeKind
, that are copied or adapted fromannos
.boolean
maybeIntegral(AnnotatedTypeMirror type)
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, addDefaultAnnotations, addSharedCFGForTree, addUncheckedStandardDefaults, analyze, applyInferredAnnotations, applyQualifierParameterDefaults, applyQualifierParameterDefaults, checkAndPerformFlowAnalysis, checkForDefaultQualifierInHierarchy, constructorFromUse, constructorFromUsePreSubstitution, createAndInitQualifierDefaults, createCFGVisualizer, createContractsFromMethod, createDefaultForTypeAnnotator, createDefaultForUseTypeAnnotator, createDependentTypesHelper, createFlowTransferFunction, createQualifierDefaults, createRequiresOrEnsuresQualifier, createTypeAnnotator, getAnnotatedTypeBefore, getAnnotatedTypeLhs, getAnnotatedTypeLhsNoTypeVarDefault, getAnnotatedTypeRhsUnaryAssign, getAnnotatedTypeVarargsArray, getAnnotationFromJavaExpression, getAnnotationFromJavaExpressionString, getAnnotationMirrorFromJavaExpressionString, getAnnotationsFromJavaExpression, getCFGVisualizer, getContractExpressions, getContractsFromMethod, getDefaultAnnotations, getDefaultForTypeAnnotator, getDefaultValueAnnotatedType, getDependentTypesHelper, getEmptyStore, getEnsuresQualifierIfResult, getExceptionalExitStore, getExplicitNewClassAnnos, getExplicitNewClassClassTypeArgs, getExpressionAndOffsetFromJavaExpressionString, getFinalLocalValues, getFirstNodeOfKindForTree, getInferredValueFor, getMethodReturnType, getNodesForTree, getQualifierPolymorphism, getRegularExitStore, getResultingTypeOfConstructorMemberReference, getReturnStatementStores, getSharedCFGForTree, getShouldDefaultTypeVarLocals, getSortedQualifierNames, getStoreAfter, getStoreAfter, getStoreAfter, getStoreBefore, getStoreBefore, getStoreBefore, getSupportedMonotonicTypeQualifiers, getTypeFactoryOfSubchecker, getTypeFactoryOfSubcheckerOrNull, handleCFGViz, irrelevantExtraMessage, isComputingAnnotatedTypeMirrorOfLhs, isNotFullyInitializedReceiver, isRelevant, isRelevant, isRelevantImpl, methodFromUse, methodFromUsePreSubstitution, parseJavaExpressionString, performFlowAnalysis, postAnalyze, postAsMemberOf, postDirectSuperTypes, postInit, preProcessClassTree, setRoot, typeVariablesFromUse
-
Methods inherited from class org.checkerframework.framework.type.AnnotatedTypeFactory
addAliasedDeclAnnotation, addAliasedDeclAnnotation, addAliasedTypeAnnotation, addAliasedTypeAnnotation, addAliasedTypeAnnotation, addAliasedTypeAnnotation, addAnnotationFromFieldInvariant, addInheritedAnnotation, applyCaptureConversion, applyCaptureConversion, applyUnboxing, areSameByClass, binaryTreeArgTypes, binaryTreeArgTypes, binaryTreeArgTypes, canonicalAnnotation, compoundAssignmentTreeArgTypes, containsSameByClass, containsUninferredTypeArguments, createAnnotatedTypeFormatter, createAnnotationClassLoader, createAnnotationFormatter, createQualifierHierarchy, createQualifierUpperBounds, createSupportedTypeQualifiers, createTypeArgumentInference, createTypeHierarchy, createTypeVariableSubstitutor, createViewpointAdapter, declarationFromElement, doesAnnotatedForApplyToThisChecker, fromElement, fromElement, fromElement, fromNewClass, getAnnotatedNullType, getAnnotatedType, getAnnotatedType, getAnnotatedType, getAnnotatedType, getAnnotatedType, getAnnotatedType, getAnnotatedType, getAnnotatedType, getAnnotatedType, getAnnotatedTypeFormatter, getAnnotatedTypeFromTypeTree, getAnnotationByClass, getAnnotationFormatter, getAnnotationMirror, getAnnotationOrTypeDeclarationBound, getAnnotationWithMetaAnnotation, getBoxedType, getBundledTypeQualifiers, getCacheSize, getChecker, getCheckerNames, getContractExpressions, getContractListValues, getCurrentClassTree, getCurrentMethodReceiver, getDeclAnnotation, getDeclAnnotationNoAliases, getDeclAnnotations, getDeclAnnotationWithMetaAnnotation, getDefaultTypeDeclarationBounds, getDummyAssignedTo, getElementUtils, getEnclosingClassOrMethod, getEnclosingSubType, getEnclosingType, getEnumConstructorQualifiers, 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, getWidenedType, getWidenedType, hasExplicitNoQualifierParameterInHierarchy, hasExplicitQualifierParameterInHierarchy, hasQualifierParameterInHierarchy, hasQualifierParameterInHierarchy, initializeReflectionResolution, isFromByteCode, isFromStubFile, isImmutable, isSideEffectFree, isSupportedQualifier, isSupportedQualifier, isSupportedQualifier, isWithinConstructor, mergeAnnotationFileAnnosIntoType, methodFromUse, negateConstant, order, parseAnnotationFiles, postProcessClassTree, replaceAnnotations, replaceAnnotations, setPathForArtificialTree, setVisitorTreePath, shouldWarnIfStubRedundantWithBytecode, toAnnotatedType, toString, type
-
-
-
-
Field Detail
-
SIGNED
protected final javax.lang.model.element.AnnotationMirror SIGNED
The @Signed annotation.
-
UNSIGNED
protected final javax.lang.model.element.AnnotationMirror UNSIGNED
The @Unsigned annotation.
-
SIGNEDNESS_GLB
protected final javax.lang.model.element.AnnotationMirror SIGNEDNESS_GLB
The @SignednessGlb annotation. Do not use @SignedPositive; use this instead.
-
SIGNED_POSITIVE
protected final javax.lang.model.element.AnnotationMirror SIGNED_POSITIVE
The @SignedPositive annotation.
-
SIGNEDNESS_BOTTOM
protected final javax.lang.model.element.AnnotationMirror SIGNEDNESS_BOTTOM
The @SignednessBottom annotation.
-
POLY_SIGNED
protected final javax.lang.model.element.AnnotationMirror POLY_SIGNED
The @PolySigned annotation.
-
-
Constructor Detail
-
SignednessAnnotatedTypeFactory
public SignednessAnnotatedTypeFactory(BaseTypeChecker checker)
Create a SignednessAnnotatedTypeFactory.- Parameters:
checker
- the type-checker associated with this type factory
-
-
Method Detail
-
addComputedTypeAnnotations
protected void addComputedTypeAnnotations(com.sun.source.tree.Tree tree, AnnotatedTypeMirror type, boolean iUseFlow)
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
-
getWidenedAnnotations
public AnnotationMirrorSet getWidenedAnnotations(AnnotationMirrorSet annos, javax.lang.model.type.TypeKind typeKind, javax.lang.model.type.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, javax.lang.model.type.TypeKind typeKind, javax.lang.model.type.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
protected TreeAnnotator 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
public AnnotationMirrorSet annotationsForIrrelevantJavaType(javax.lang.model.type.TypeMirror tm)
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
public boolean maybeIntegral(AnnotatedTypeMirror type)
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, com.sun.source.tree.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 javax.lang.model.element.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
protected QualifierPolymorphism 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
-
-