示例#1
0
            public override PointsToAbstractValue VisitDelegateCreation(IDelegateCreationOperation operation, object argument)
            {
                var _ = base.VisitDelegateCreation(operation, argument);
                AbstractLocation location = AbstractLocation.CreateAllocationLocation(operation, operation.Type);

                return(new PointsToAbstractValue(location));
            }
示例#2
0
            public override PointsToAbstractValue VisitAnonymousObjectCreation(IAnonymousObjectCreationOperation operation, object argument)
            {
                AbstractLocation location = AbstractLocation.CreateAllocationLocation(operation, operation.Type);
                var pointsToAbstractValue = new PointsToAbstractValue(location);

                CacheAbstractValue(operation, pointsToAbstractValue);

                var _ = VisitArray(operation.Initializers, argument);

                return(pointsToAbstractValue);
            }
示例#3
0
            protected override PointsToAbstractValue ComputeAnalysisValueForOutArgument(AnalysisEntity analysisEntity, IArgumentOperation operation, PointsToAbstractValue defaultValue)
            {
                if (analysisEntity.Type.HasValueCopySemantics())
                {
                    return(PointsToAbstractValue.NoLocation);
                }

                var location = AbstractLocation.CreateAllocationLocation(operation, analysisEntity.Type);

                return(new PointsToAbstractValue(location));
            }
示例#4
0
            public override PointsToAbstractValue VisitAnonymousObjectCreation(IAnonymousObjectCreationOperation operation, object argument)
            {
                AbstractLocation location = AbstractLocation.CreateAllocationLocation(operation, operation.Type);
                var pointsToAbstractValue = PointsToAbstractValue.Create(location, mayBeNull: false);

                CacheAbstractValue(operation, pointsToAbstractValue);

                var _ = base.VisitAnonymousObjectCreation(operation, argument);

                return(pointsToAbstractValue);
            }
示例#5
0
            protected override PointsToAbstractValue ComputeAnalysisValueForOutArgument(AnalysisEntity analysisEntity, IArgumentOperation operation, PointsToAbstractValue defaultValue)
            {
                if (!ShouldBeTracked(analysisEntity.Type))
                {
                    return(PointsToAbstractValue.NoLocation);
                }

                var location = AbstractLocation.CreateAllocationLocation(operation, analysisEntity.Type);

                return(PointsToAbstractValue.Create(location, mayBeNull: true));
            }
示例#6
0
 private static PointsToAbstractValue VisitInvocationCommon(IOperation operation)
 {
     if (!operation.Type.HasValueCopySemantics())
     {
         AbstractLocation location = AbstractLocation.CreateAllocationLocation(operation, operation.Type);
         return(new PointsToAbstractValue(location));
     }
     else
     {
         return(PointsToAbstractValue.NoLocation);
     }
 }
示例#7
0
            public override PointsToAbstractValue VisitArrayCreation(IArrayCreationOperation operation, object argument)
            {
                var pointsToAbstractValue = new PointsToAbstractValue(AbstractLocation.CreateAllocationLocation(operation, operation.Type));

                CacheAbstractValue(operation, pointsToAbstractValue);

                var unusedDimensionsValue = VisitArray(operation.DimensionSizes, argument);
                var initializerValue      = Visit(operation.Initializer, argument);

                Debug.Assert(operation.Initializer == null || initializerValue == pointsToAbstractValue);
                return(pointsToAbstractValue);
            }
 private static PointsToAbstractValue VisitInvocationCommon(IOperation operation)
 {
     if (operation.Type.IsReferenceType)
     {
         AbstractLocation location = AbstractLocation.CreateAllocationLocation(operation, operation.Type);
         return(new PointsToAbstractValue(location));
     }
     else
     {
         return(PointsToAbstractValue.NoLocation);
     }
 }
示例#9
0
            private PointsToAbstractValue VisitTypeCreationWithArgumentsAndInitializer(IEnumerable <IOperation> arguments, IObjectOrCollectionInitializerOperation initializer, IOperation operation, object argument)
            {
                AbstractLocation location = AbstractLocation.CreateAllocationLocation(operation, operation.Type);
                var pointsToAbstractValue = new PointsToAbstractValue(location);

                CacheAbstractValue(operation, pointsToAbstractValue);

                var unusedArray      = VisitArray(arguments, argument);
                var initializerValue = Visit(initializer, argument);

                Debug.Assert(initializer == null || initializerValue == pointsToAbstractValue);
                return(pointsToAbstractValue);
            }
示例#10
0
 private PointsToAbstractValue VisitInvocationCommon(IOperation operation, IOperation instance)
 {
     if (ShouldBeTracked(operation.Type))
     {
         AbstractLocation location = AbstractLocation.CreateAllocationLocation(operation, operation.Type);
         var pointsToAbstractValue = PointsToAbstractValue.Create(location, mayBeNull: true);
         return(GetValueBasedOnInstanceOrReferenceValue(referenceOrInstance: instance, operation: operation, defaultValue: pointsToAbstractValue));
     }
     else
     {
         return(PointsToAbstractValue.NoLocation);
     }
 }
示例#11
0
            protected override PointsToAbstractValue ComputeAnalysisValueForReferenceOperation(IOperation operation, PointsToAbstractValue defaultValue)
            {
                if (!operation.Type.HasValueCopySemantics() &&
                    AnalysisEntityFactory.TryCreate(operation, out AnalysisEntity analysisEntity))
                {
                    if (!HasAbstractValue(analysisEntity))
                    {
                        var value = new PointsToAbstractValue(AbstractLocation.CreateAllocationLocation(operation, operation.Type));
                        SetAbstractValue(analysisEntity, value);
                        return(value);
                    }

                    return(GetAbstractValue(analysisEntity));
                }
                else
                {
                    Debug.Assert(!operation.Type.HasValueCopySemantics() || defaultValue == PointsToAbstractValue.NoLocation);
                    return(defaultValue);
                }
            }
示例#12
0
            public override PointsToAbstractValue VisitParameterReference(IParameterReferenceOperation operation, object argument)
            {
                // Create a dummy PointsTo value for each reference type parameter.
                if (!operation.Type.HasValueCopySemantics())
                {
                    var result = AnalysisEntityFactory.TryCreateForSymbolDeclaration(operation.Parameter, out AnalysisEntity analysisEntity);
                    Debug.Assert(result);
                    if (!HasAbstractValue(analysisEntity))
                    {
                        var value = new PointsToAbstractValue(AbstractLocation.CreateAllocationLocation(operation, operation.Parameter.Type));
                        SetAbstractValue(analysisEntity, value);
                        return(value);
                    }

                    return(GetAbstractValue(analysisEntity));
                }
                else
                {
                    return(PointsToAbstractValue.NoLocation);
                }
            }
        public PointsToAbstractValue MakeNonNull(IOperation operation)
        {
            if (NullState == NullAbstractValue.NotNull)
            {
                return(this);
            }

            if (Kind != PointsToAbstractValueKind.Known)
            {
                return(Create(AbstractLocation.CreateAllocationLocation(operation, operation.Type), mayBeNull: false));
            }

            var locations = Locations.Where(location => !location.IsNull).ToImmutableHashSet();

            if (locations.Count == Locations.Count)
            {
                locations = Locations;
            }

            return(new PointsToAbstractValue(locations, NullAbstractValue.NotNull));
        }
示例#14
0
            public override PointsToAbstractValue VisitMemberInitializer(IMemberInitializerOperation operation, object argument)
            {
                if (operation.InitializedMember is IMemberReferenceOperation memberReference)
                {
                    IOperation            objectCreation         = operation.GetCreation();
                    PointsToAbstractValue objectCreationLocation = GetCachedAbstractValue(objectCreation);
                    Debug.Assert(objectCreationLocation.Kind == PointsToAbstractValueKind.Known);
                    Debug.Assert(objectCreationLocation.Locations.Count == 1);

                    PointsToAbstractValue memberInstanceLocation = new PointsToAbstractValue(AbstractLocation.CreateAllocationLocation(operation, memberReference.Type));
                    CacheAbstractValue(operation, memberInstanceLocation);
                    CacheAbstractValue(operation.Initializer, memberInstanceLocation);

                    var unusedInitializedMemberValue = Visit(memberReference, argument);
                    var initializerValue             = Visit(operation.Initializer, argument);
                    Debug.Assert(operation.Initializer == null || initializerValue == memberInstanceLocation);
                    SetAbstractValueForAssignment(memberReference, operation, memberInstanceLocation);

                    return(memberInstanceLocation);
                }

                var _ = base.Visit(operation, argument);

                return(PointsToAbstractValue.NoLocation);
            }