public override void VisitPrefixUnaryExpression(PrefixUnaryExpressionSyntax node)
 {
     base.VisitPrefixUnaryExpression(node);
     if (node.IsKind(SyntaxKind.AddressOfExpression) || node.IsKind(SyntaxKind.PointerIndirectionExpression))  // TODO: Check
     {
         MarkUnsafe();
     }
 }
Exemple #2
0
 public override void VisitPrefixUnaryExpression(PrefixUnaryExpressionSyntax node)
 {
     if (node.IsKind(SyntaxKind.PreDecrementExpression) || node.IsKind(SyntaxKind.PreIncrementExpression))
     {
         var variables = GetAllKnownVariablesInSyntaxTree(node.Operand).ToList();
         if (variables.Count == 0)
         {
             Console.WriteLine("Could not determine written variable in assignment '{0}'", node);
             return;
         }
         var writtenVar = variables.First();
         RecordFlow(_varToLastWritesStack.Peek(), writtenVar.Item1, writtenVar.Item2, SourceGraphEdge.LastWrite);
     }
     base.VisitPrefixUnaryExpression(node);
 }
        public override SyntaxNode?VisitPrefixUnaryExpression(PrefixUnaryExpressionSyntax node)
        {
            var res = base.VisitPrefixUnaryExpression(node);

            if (node.IsKind(SyntaxKind.PreDecrementExpression) ||
                node.IsKind(SyntaxKind.PreIncrementExpression) ||
                node.IsKind(SyntaxKind.PointerIndirectionExpression))
            {
                var previous = node.OperatorToken.GetPreviousToken();
                if (!previous.IsKind(SyntaxKind.SemicolonToken) && !previous.IsKind(SyntaxKind.ColonToken))
                {
                    return(res?.WithLeadingTrivia(SyntaxFactory.Space));
                }
            }
            return(res);
        }
Exemple #4
0
        private static void AddPrefixUnaryExpressionTerms(
            PrefixUnaryExpressionSyntax prefixUnaryExpression,
            IList <string> terms,
            ref ExpressionType expressionType
            )
        {
            expressionType = ExpressionType.Invalid;
            var flags = ExpressionType.Invalid;

            // Ask our subexpression for terms
            AddSubExpressionTerms(prefixUnaryExpression.Operand, terms, ref flags);

            // Is our expression a valid term?
            AddIfValidTerm(prefixUnaryExpression.Operand, flags, terms);

            if (
                prefixUnaryExpression.IsKind(
                    SyntaxKind.LogicalNotExpression,
                    SyntaxKind.BitwiseNotExpression,
                    SyntaxKind.UnaryMinusExpression,
                    SyntaxKind.UnaryPlusExpression
                    )
                )
            {
                // We're a valid expression if our subexpression is...
                expressionType = flags & ExpressionType.ValidExpression;
            }
        }
Exemple #5
0
 public override SyntaxNode VisitPrefixUnaryExpression(PrefixUnaryExpressionSyntax node)
 {
     if (node.IsKind(SK.PreIncrementExpression) ||
         node.IsKind(SK.PreDecrementExpression))
     {
         var identifier = ((IdentifierNameSyntax)node.Operand).Identifier.Text;
         SMS.Update(identifier, node);
     }
     else if (node.IsKind(SK.UnaryMinusExpression))
     {
         return(base.VisitPrefixUnaryExpression(node));
     }
     else
     {
         throw new NotImplementedException("Unsupported PrefixUnaryExpression: " + node.Kind());
     }
     return(base.VisitPrefixUnaryExpression(node));
 }
 public override void VisitPrefixUnaryExpression(PrefixUnaryExpressionSyntax node)
 {
     if (node.IsKind(SyntaxKind.PreIncrementExpression, SyntaxKind.PreDecrementExpression) &&
         FieldSymbol.Type.TypeKind == TypeKind.Struct &&
         IsAssigned(node.Operand))
     {
         Success = false;
     }
     else
     {
         base.VisitPrefixUnaryExpression(node);
     }
 }
        public override void VisitPrefixUnaryExpression(PrefixUnaryExpressionSyntax node)
        {
            if (node.IsKind(SyntaxKind.PreIncrementExpression, SyntaxKind.PreDecrementExpression))
            {
                ExpressionSyntax operand = node.Operand;

                VisitAssignedExpression(operand);
                Visit(operand);
            }
            else
            {
                base.VisitPrefixUnaryExpression(node);
            }
        }
Exemple #8
0
 public override void VisitPrefixUnaryExpression(PrefixUnaryExpressionSyntax node)
 {
     if (node.OperatorToken.Kind() == SyntaxKind.AmpersandToken)
     {
         Visit(node.Operand);
     }
     else if (node.IsKind(SyntaxKind.UnaryMinusExpression))
     {
         Visit(node.Operand);
         InjectRequiredConversions(node.Operand);
         AddCilInstruction(ilVar, OpCodes.Neg);
     }
     else if (node.IsKind(SyntaxKind.PreDecrementExpression))
     {
         ProcessPrefixPostfixOperators(node.Operand, OpCodes.Sub, true);
     }
     else if (node.IsKind(SyntaxKind.PreIncrementExpression))
     {
         ProcessPrefixPostfixOperators(node.Operand, OpCodes.Add, true);
     }
     else if (node.IsKind(SyntaxKind.LogicalNotExpression))
     {
         node.Operand.Accept(this);
         AddCilInstruction(ilVar, OpCodes.Ldc_I4_0);
         AddCilInstruction(ilVar, OpCodes.Ceq);
     }
     else if (node.IsKind(SyntaxKind.BitwiseNotExpression))
     {
         node.Operand.Accept(this);
         AddCilInstruction(ilVar, OpCodes.Not);
     }
     else
     {
         LogUnsupportedSyntax(node);
     }
 }
 public override void VisitPrefixUnaryExpression(PrefixUnaryExpressionSyntax node)
 {
     base.VisitPrefixUnaryExpression(node);
     if (node.IsKind(SyntaxKind.AddressOfExpression) || node.IsKind(SyntaxKind.PointerIndirectionExpression))  // TODO: Check
         MarkUnsafe();
 }
        private static void AddPrefixUnaryExpressionTerms(PrefixUnaryExpressionSyntax prefixUnaryExpression, IList<string> terms, ref ExpressionType expressionType)
        {
            expressionType = ExpressionType.Invalid;
            var flags = ExpressionType.Invalid;

            // Ask our subexpression for terms
            AddSubExpressionTerms(prefixUnaryExpression.Operand, terms, ref flags);

            // Is our expression a valid term?
            AddIfValidTerm(prefixUnaryExpression.Operand, flags, terms);

            if (prefixUnaryExpression.IsKind(SyntaxKind.LogicalNotExpression, SyntaxKind.BitwiseNotExpression, SyntaxKind.UnaryMinusExpression, SyntaxKind.UnaryPlusExpression))
            {
                // We're a valid expression if our subexpression is...
                expressionType = flags & ExpressionType.ValidExpression;
            }
        }
            public override void VisitPrefixUnaryExpression(PrefixUnaryExpressionSyntax node)
            {
                base.VisitPrefixUnaryExpression(node);

                if (node.IsKind(SyntaxKind.PreDecrementExpression) || node.IsKind(SyntaxKind.PreIncrementExpression))
                {
                    var postfixed = node.Operand;

                    if (postfixed.IsKind(SyntaxKind.IdentifierName))
                    {
                        var identifier = (IdentifierNameSyntax)postfixed;

                        if (identifier.Identifier.Text == _testee.Name)
                        {
                            _isAssigned = true;
                        }
                    }
                }
            }