/// <summary> /// Constructor. /// </summary> /// <param name="symbol">ISymbol</param> /// <param name="dfgNode">DataFlowNode</param> 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}"; }
/// <summary> /// Creates the control-flow graph nodes of the /// specified method summary. /// </summary> /// <param name="dfg">DataFlowGraph</param> /// <param name="summary">MethodSummary</param> /// <returns>IDataFlowNode</returns> 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); }
/// <summary> /// Constructor. /// </summary> /// <param name="summary">MethodSummary</param> internal DataFlowGraph(MethodSummary summary) : base() { this.Summary = summary; this.SemanticModel = summary.SemanticModel; base.EntryNode = DataFlowNode.Create(this, summary); base.MergeEmptyNodes(); }
/// <summary> /// Constructor. /// </summary> /// <param name="dfgNode">DataFlowNode</param> /// <param name="context">AnalysisContext</param> 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> >(); }
/// <summary> /// Constructs the data-flow graph node from the /// specified control-flow graph node. /// </summary> /// <param name="cfgNode">IControlFlowNode</param> /// <param name="previous">DataFlowNode</param> /// <param name="visited">Visited nodes</param> 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); } }