protected virtual void SetAbstractValueForAssignment(AnalysisEntity targetAnalysisEntity, IOperation?assignedValueOperation, TAbstractAnalysisValue assignedValue) { AnalysisEntity?assignedValueEntity = null; if (assignedValueOperation != null) { var success = AnalysisEntityFactory.TryCreate(assignedValueOperation, out assignedValueEntity); Debug.Assert(success || assignedValueEntity == null); } SetAbstractValueForAssignment(targetAnalysisEntity, assignedValueEntity, assignedValueOperation, assignedValue); }
protected override void SetAbstractValueForAssignment(IOperation target, IOperation assignedValueOperation, TAbstractAnalysisValue assignedValue, bool mayBeAssignment = false) { if (AnalysisEntityFactory.TryCreate(target, out AnalysisEntity targetAnalysisEntity)) { if (mayBeAssignment) { assignedValue = ValueDomain.Merge(GetAbstractValue(targetAnalysisEntity), assignedValue); } SetAbstractValueForAssignment(targetAnalysisEntity, assignedValueOperation, assignedValue); } }
protected sealed override TAbstractAnalysisValue ComputeAnalysisValueForEscapedRefOrOutArgument(IArgumentOperation operation, TAbstractAnalysisValue defaultValue) { Debug.Assert(operation.Parameter.RefKind is RefKind.Ref or RefKind.Out); if (AnalysisEntityFactory.TryCreate(operation, out var analysisEntity)) { var value = ComputeAnalysisValueForEscapedRefOrOutArgument(analysisEntity, operation, defaultValue); SetAbstractValueForAssignment(analysisEntity, operation, value); return(GetAbstractValue(analysisEntity)); } else { return(defaultValue); } }
protected override TAbstractAnalysisValue ComputeAnalysisValueForReferenceOperation(IOperation operation, TAbstractAnalysisValue defaultValue) { if (AnalysisEntityFactory.TryCreate(operation, out var analysisEntity)) { if (!HasAbstractValue(analysisEntity)) { SetAbstractValue(analysisEntity, defaultValue); } return(GetAbstractValue(analysisEntity)); } else { return(defaultValue); } }
protected override void SetAbstractValueForAssignment(IOperation target, IOperation?assignedValueOperation, TAbstractAnalysisValue assignedValue, bool mayBeAssignment = false) { if (AnalysisEntityFactory.TryCreate(target, out var targetAnalysisEntity)) { if (!HasCompletePointsToAnalysisResult && targetAnalysisEntity.IsChildOrInstanceMemberNeedingCompletePointsToAnalysis()) { // We are not tracking points to values for fields and properties. // So, it is not possible to accurately track value changes to target entity which is a member. // Conservatively assume that the entity is assigned an unknown value. assignedValue = ValueDomain.UnknownOrMayBeValue; } else if (mayBeAssignment) { assignedValue = ValueDomain.Merge(GetAbstractValue(targetAnalysisEntity), assignedValue); } SetAbstractValueForAssignment(targetAnalysisEntity, assignedValueOperation, assignedValue); } }