Beispiel #1
0
        /// <summary>
        /// Constructs the data-flow graph node from the specified control-flow graph node.
        /// </summary>
        private void Construct(IControlFlowNode cfgNode, DataFlowNode previous, Dictionary <IControlFlowNode, DataFlowNode> visited)
        {
            visited.Add(cfgNode, this);

            if (cfgNode.Statements.Count > 0)
            {
                this.Statement = cfgNode.Statements[0];
            }

            previous = this;
            for (int idx = 1; idx < cfgNode.Statements.Count; idx++)
            {
                var nextNode = new DataFlowNode(this.Graph, cfgNode, this.Summary);
                nextNode.Statement = cfgNode.Statements[idx];

                previous.ISuccessors.Add(nextNode);
                nextNode.IPredecessors.Add(previous);
                previous = nextNode;
            }

            foreach (var successor in cfgNode.ISuccessors)
            {
                if (visited.ContainsKey(successor))
                {
                    previous.ISuccessors.Add(visited[successor]);
                    visited[successor].IPredecessors.Add(previous);
                    continue;
                }

                var nextNode = new DataFlowNode(this.Graph, successor, this.Summary);
                nextNode.Construct(successor, previous, visited);
                previous.ISuccessors.Add(nextNode);
                nextNode.IPredecessors.Add(previous);
            }
        }
Beispiel #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SymbolDefinition"/> class.
 /// </summary>
 internal SymbolDefinition(ISymbol symbol, DataFlowNode dfgNode)
 {
     this.DataFlowNode   = dfgNode;
     this.Symbol         = symbol;
     this.CandidateTypes = new HashSet <ITypeSymbol>();
     this.Kind           = symbol.Kind;
     this.Name           = $"[{this.DataFlowNode.Id},{this.Kind}]::{this.Symbol.Name}";
 }
Beispiel #3
0
        /// <summary>
        /// Creates the control-flow graph nodes of the specified method summary.
        /// </summary>
        internal static IDataFlowNode Create(DataFlowGraph dfg, MethodSummary summary)
        {
            var entryNode = new DataFlowNode(dfg, summary.ControlFlowGraph.EntryNode, summary);

            entryNode.Construct(summary.ControlFlowGraph.EntryNode, null,
                                new Dictionary <IControlFlowNode, DataFlowNode>());
            return(entryNode);
        }
Beispiel #4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="DataFlowGraph"/> class.
        /// </summary>
        internal DataFlowGraph(MethodSummary summary)
            : base()
        {
            this.Summary       = summary;
            this.SemanticModel = summary.SemanticModel;

            this.EntryNode = DataFlowNode.Create(this, summary);
            this.MergeEmptyNodes();
        }
Beispiel #5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DataFlowInfo"/> class.
 /// </summary>
 internal DataFlowInfo(DataFlowNode dfgNode, AnalysisContext context)
 {
     this.AnalysisContext      = context;
     this.DataFlowNode         = dfgNode;
     this.GeneratedDefinitions = new HashSet <SymbolDefinition>();
     this.KilledDefinitions    = new HashSet <SymbolDefinition>();
     this.InputDefinitions     = new HashSet <SymbolDefinition>();
     this.OutputDefinitions    = new HashSet <SymbolDefinition>();
     this.TaintedDefinitions   = new Dictionary <SymbolDefinition, ISet <SymbolDefinition> >();
 }