1 instantiation of ControlFlowGraph
Microsoft.CodeAnalysis (1)
281 references to ControlFlowGraph
ILLink.RoslynAnalyzer (18)
Microsoft.CodeAnalysis (86)
DiagnosticAnalyzer\DiagnosticAnalysisContext.cs (12)
1240private readonly Func<IOperation, ControlFlowGraph>? _getControlFlowGraph;
1305Func<IOperation, ControlFlowGraph>? getControlFlowGraph,
1351/// Gets a <see cref="ControlFlowGraph"/> for a given <paramref name="operationBlock"/> from this analysis context's <see cref="OperationBlocks"/>.
1354public ControlFlowGraph GetControlFlowGraph(IOperation operationBlock)
1382private readonly Func<IOperation, ControlFlowGraph>? _getControlFlowGraph;
1451Func<IOperation, ControlFlowGraph>? getControlFlowGraph,
1484/// Gets a <see cref="ControlFlowGraph"/> for a given <paramref name="operationBlock"/> from this analysis context's <see cref="OperationBlocks"/>.
1487public ControlFlowGraph GetControlFlowGraph(IOperation operationBlock)
1776private readonly Func<IOperation, ControlFlowGraph>? _getControlFlowGraph;
1841Func<IOperation, ControlFlowGraph>? getControlFlowGraph,
1873/// Gets a <see cref="ControlFlowGraph"/> for the operation block containing the <see cref="Operation"/>.
1875public ControlFlowGraph GetControlFlowGraph() => DiagnosticAnalysisContextHelpers.GetControlFlowGraph(Operation, _getControlFlowGraph, _cancellationToken);
Operations\ControlFlowGraph.cs (35)
28private ControlFlowGraph?[]? _lazyLocalFunctionsGraphs;
30private ControlFlowGraph?[]? _lazyAnonymousFunctionsGraphs;
33ControlFlowGraph? parent,
74/// Creates a <see cref="ControlFlowGraph"/> for the given executable code block root <paramref name="node"/>.
81/// Otherwise, returns a <see cref="ControlFlowGraph"/> for the executable code block.
83public static ControlFlowGraph? Create(SyntaxNode node, SemanticModel semanticModel, CancellationToken cancellationToken = default)
101/// Creates a <see cref="ControlFlowGraph"/> for the given executable code block <paramref name="body"/>.
105public static ControlFlowGraph Create(Operations.IBlockOperation body, CancellationToken cancellationToken = default)
111/// Creates a <see cref="ControlFlowGraph"/> for the given executable code block <paramref name="initializer"/>.
115public static ControlFlowGraph Create(Operations.IFieldInitializerOperation initializer, CancellationToken cancellationToken = default)
121/// Creates a <see cref="ControlFlowGraph"/> for the given executable code block <paramref name="initializer"/>.
125public static ControlFlowGraph Create(Operations.IPropertyInitializerOperation initializer, CancellationToken cancellationToken = default)
131/// Creates a <see cref="ControlFlowGraph"/> for the given executable code block <paramref name="initializer"/>.
135public static ControlFlowGraph Create(Operations.IParameterInitializerOperation initializer, CancellationToken cancellationToken = default)
141/// Creates a <see cref="ControlFlowGraph"/> for the given executable code block <paramref name="attribute"/>.
145public static ControlFlowGraph Create(Operations.IAttributeOperation attribute, CancellationToken cancellationToken = default)
151/// Creates a <see cref="ControlFlowGraph"/> for the given executable code block <paramref name="constructorBody"/>.
155public static ControlFlowGraph Create(Operations.IConstructorBodyOperation constructorBody, CancellationToken cancellationToken = default)
161/// Creates a <see cref="ControlFlowGraph"/> for the given executable code block <paramref name="methodBody"/>.
165public static ControlFlowGraph Create(Operations.IMethodBodyOperation methodBody, CancellationToken cancellationToken = default)
171internal static ControlFlowGraph CreateCore(IOperation operation, string argumentNameForException, CancellationToken cancellationToken)
190ControlFlowGraph controlFlowGraph = ControlFlowGraphBuilder.Create(operation);
207public ControlFlowGraph? Parent { get; }
227public ControlFlowGraph GetLocalFunctionControlFlowGraph(IMethodSymbol localFunction, CancellationToken cancellationToken = default)
236if (!TryGetLocalFunctionControlFlowGraph(localFunction, out var controlFlowGraph))
244internal bool TryGetLocalFunctionControlFlowGraph(IMethodSymbol localFunction, [NotNullWhen(true)] out ControlFlowGraph? controlFlowGraph)
256Interlocked.CompareExchange(ref _lazyLocalFunctionsGraphs, new ControlFlowGraph[LocalFunctions.Length], null);
259ref ControlFlowGraph? localFunctionGraph = ref _lazyLocalFunctionsGraphs[info.ordinal];
263ControlFlowGraph graph = ControlFlowGraphBuilder.Create(info.operation, this, info.enclosing, _captureIdDispenser);
276public ControlFlowGraph GetAnonymousFunctionControlFlowGraph(IFlowAnonymousFunctionOperation anonymousFunction, CancellationToken cancellationToken = default)
285if (!TryGetAnonymousFunctionControlFlowGraph(anonymousFunction, out ControlFlowGraph? controlFlowGraph))
293internal bool TryGetAnonymousFunctionControlFlowGraph(IFlowAnonymousFunctionOperation anonymousFunction, [NotNullWhen(true)] out ControlFlowGraph? controlFlowGraph)
303Interlocked.CompareExchange(ref _lazyAnonymousFunctionsGraphs, new ControlFlowGraph[_anonymousFunctionsMap.Count], null);
306ref ControlFlowGraph? anonymousFlowGraph = ref _lazyAnonymousFunctionsGraphs[info.ordinal];
310ControlFlowGraph graph = ControlFlowGraphBuilder.Create(anonymous.Original, this, info.enclosing, _captureIdDispenser, in anonymous.Context);
Microsoft.CodeAnalysis.CodeStyle (43)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\FlowAnalysis\SymbolUsageAnalysis\SymbolUsageAnalysis.DataFlowAnalyzer.FlowGraphAnalysisData.cs (29)
36private readonly Func<IMethodSymbol, ControlFlowGraph, AnalysisData, CancellationToken, BasicBlockAnalysisData> _analyzeLocalFunctionOrLambdaInvocation;
55private readonly PooledDictionary<IMethodSymbol, ControlFlowGraph> _localFunctionTargetsToAccessingCfgMap;
62private readonly PooledDictionary<IFlowAnonymousFunctionOperation, ControlFlowGraph> _lambdaTargetsToAccessingCfgMap;
72ControlFlowGraph controlFlowGraph,
80Func<IMethodSymbol, ControlFlowGraph, AnalysisData, CancellationToken, BasicBlockAnalysisData> analyzeLocalFunctionOrLambdaInvocation,
82PooledDictionary<IMethodSymbol, ControlFlowGraph> localFunctionTargetsToAccessingCfgMap,
83PooledDictionary<IFlowAnonymousFunctionOperation, ControlFlowGraph> lambdaTargetsToAccessingCfgMap)
117ControlFlowGraph cfg,
119Func<IMethodSymbol, ControlFlowGraph, AnalysisData, CancellationToken, BasicBlockAnalysisData> analyzeLocalFunctionOrLambdaInvocation)
135localFunctionTargetsToAccessingCfgMap: PooledDictionary<IMethodSymbol, ControlFlowGraph>.GetInstance(),
136lambdaTargetsToAccessingCfgMap: PooledDictionary<IFlowAnonymousFunctionOperation, ControlFlowGraph>.GetInstance());
140ControlFlowGraph cfg,
165ControlFlowGraph cfg)
176public ControlFlowGraph ControlFlowGraph { get; }
187private static ImmutableHashSet<ILocalSymbol> GetCapturedLocals(ControlFlowGraph cfg)
239ControlFlowGraph cfg,
261var localFunctionGraph = cfg.GetLocalFunctionControlFlowGraphInScope(invocation.TargetMethod.OriginalDefinition, cancellationToken);
278ControlFlowGraph lambdaOrLocalFunctionCfgOpt = null;
302void AddDescendantOperationsInLambdaOrLocalFunctionGraph(ControlFlowGraph lambdaOrLocalFunctionCfg)
309ControlFlowGraph TryGetAnonymousFunctionControlFlowGraphInScope(IFlowAnonymousFunctionOperation flowAnonymousFunctionOperation)
311if (_lambdaTargetsToAccessingCfgMap.TryGetValue(flowAnonymousFunctionOperation, out var lambdaAccessingCfg))
313var anonymousFunctionCfg = lambdaAccessingCfg.GetAnonymousFunctionControlFlowGraphInScope(flowAnonymousFunctionOperation, cancellationToken);
321ControlFlowGraph TryGetLocalFunctionControlFlowGraphInScope(IMethodSymbol localFunction)
328if (_localFunctionTargetsToAccessingCfgMap.TryGetValue(localFunction, out var localFunctionAccessingCfg))
330var localFunctionCfg = localFunctionAccessingCfg.GetLocalFunctionControlFlowGraphInScope(localFunction, cancellationToken);
492if (!_localFunctionTargetsToAccessingCfgMap.TryGetValue(localFunction, out var accessingCfg))
497var localFunctionCfg = accessingCfg.GetLocalFunctionControlFlowGraphInScope(localFunction, cancellationToken);
504if (!_lambdaTargetsToAccessingCfgMap.TryGetValue(lambda, out var accessingCfg))
509var lambdaCfg = accessingCfg.GetAnonymousFunctionControlFlowGraphInScope(lambda, cancellationToken);
Microsoft.CodeAnalysis.CSharp.Emit.UnitTests (3)
Microsoft.CodeAnalysis.CSharp.Emit3.UnitTests (2)
Microsoft.CodeAnalysis.CSharp.EndToEnd.UnitTests (3)
Microsoft.CodeAnalysis.CSharp.IOperation.UnitTests (24)
Microsoft.CodeAnalysis.CSharp.Semantic.UnitTests (6)
Microsoft.CodeAnalysis.CSharp.Test.Utilities (1)
Microsoft.CodeAnalysis.Features (1)
Microsoft.CodeAnalysis.Test.Utilities (29)
Compilation\ControlFlowGraphVerifier.cs (22)
28public static (ControlFlowGraph graph, ISymbol associatedSymbol) GetControlFlowGraph(SyntaxNode syntaxNode, SemanticModel model)
41ControlFlowGraph graph;
45graph = ControlFlowGraph.Create(blockOperation);
49graph = ControlFlowGraph.Create(methodBodyOperation);
53graph = ControlFlowGraph.Create(constructorBodyOperation);
57graph = ControlFlowGraph.Create(fieldInitializerOperation);
61graph = ControlFlowGraph.Create(propertyInitializerOperation);
65graph = ControlFlowGraph.Create(parameterInitializerOperation);
69graph = ControlFlowGraph.Create(attributeOperation);
82public static void VerifyGraph(Compilation compilation, string expectedFlowGraph, ControlFlowGraph graph, ISymbol associatedSymbol)
98public static string GetFlowGraph(Compilation compilation, ControlFlowGraph graph, ISymbol associatedSymbol)
108private static void GetFlowGraph(System.Text.StringBuilder stringBuilder, Compilation compilation, ControlFlowGraph graph,
117var localFunctionsMap = PooledDictionary<IMethodSymbol, ControlFlowGraph>.GetInstance();
118var anonymousFunctionsMap = PooledDictionary<IFlowAnonymousFunctionOperation, ControlFlowGraph>.GetInstance();
330ControlFlowGraph g = localFunctionsMap[m];
338foreach (KeyValuePair<IFlowAnonymousFunctionOperation, ControlFlowGraph> pair in anonymousFunctionsMap)
1522var g = graph.GetLocalFunctionControlFlowGraph(method);
1797private readonly ControlFlowGraph _graph;
1800private readonly Dictionary<IFlowAnonymousFunctionOperation, ControlFlowGraph> _anonymousFunctionsMap;
1803public OperationTreeSerializer(ControlFlowGraph graph, ControlFlowRegion region, string idSuffix,
1804Dictionary<IFlowAnonymousFunctionOperation, ControlFlowGraph> anonymousFunctionsMap,
1823var g = _graph.GetAnonymousFunctionControlFlowGraph(operation);
Microsoft.CodeAnalysis.UnitTests (20)
Microsoft.CodeAnalysis.VisualBasic.Semantic.UnitTests (2)
Microsoft.CodeAnalysis.VisualBasic.Test.Utilities (1)
Microsoft.CodeAnalysis.Workspaces (42)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\FlowAnalysis\SymbolUsageAnalysis\SymbolUsageAnalysis.DataFlowAnalyzer.FlowGraphAnalysisData.cs (29)
36private readonly Func<IMethodSymbol, ControlFlowGraph, AnalysisData, CancellationToken, BasicBlockAnalysisData> _analyzeLocalFunctionOrLambdaInvocation;
55private readonly PooledDictionary<IMethodSymbol, ControlFlowGraph> _localFunctionTargetsToAccessingCfgMap;
62private readonly PooledDictionary<IFlowAnonymousFunctionOperation, ControlFlowGraph> _lambdaTargetsToAccessingCfgMap;
72ControlFlowGraph controlFlowGraph,
80Func<IMethodSymbol, ControlFlowGraph, AnalysisData, CancellationToken, BasicBlockAnalysisData> analyzeLocalFunctionOrLambdaInvocation,
82PooledDictionary<IMethodSymbol, ControlFlowGraph> localFunctionTargetsToAccessingCfgMap,
83PooledDictionary<IFlowAnonymousFunctionOperation, ControlFlowGraph> lambdaTargetsToAccessingCfgMap)
117ControlFlowGraph cfg,
119Func<IMethodSymbol, ControlFlowGraph, AnalysisData, CancellationToken, BasicBlockAnalysisData> analyzeLocalFunctionOrLambdaInvocation)
135localFunctionTargetsToAccessingCfgMap: PooledDictionary<IMethodSymbol, ControlFlowGraph>.GetInstance(),
136lambdaTargetsToAccessingCfgMap: PooledDictionary<IFlowAnonymousFunctionOperation, ControlFlowGraph>.GetInstance());
140ControlFlowGraph cfg,
165ControlFlowGraph cfg)
176public ControlFlowGraph ControlFlowGraph { get; }
187private static ImmutableHashSet<ILocalSymbol> GetCapturedLocals(ControlFlowGraph cfg)
239ControlFlowGraph cfg,
261var localFunctionGraph = cfg.GetLocalFunctionControlFlowGraphInScope(invocation.TargetMethod.OriginalDefinition, cancellationToken);
278ControlFlowGraph lambdaOrLocalFunctionCfgOpt = null;
302void AddDescendantOperationsInLambdaOrLocalFunctionGraph(ControlFlowGraph lambdaOrLocalFunctionCfg)
309ControlFlowGraph TryGetAnonymousFunctionControlFlowGraphInScope(IFlowAnonymousFunctionOperation flowAnonymousFunctionOperation)
311if (_lambdaTargetsToAccessingCfgMap.TryGetValue(flowAnonymousFunctionOperation, out var lambdaAccessingCfg))
313var anonymousFunctionCfg = lambdaAccessingCfg.GetAnonymousFunctionControlFlowGraphInScope(flowAnonymousFunctionOperation, cancellationToken);
321ControlFlowGraph TryGetLocalFunctionControlFlowGraphInScope(IMethodSymbol localFunction)
328if (_localFunctionTargetsToAccessingCfgMap.TryGetValue(localFunction, out var localFunctionAccessingCfg))
330var localFunctionCfg = localFunctionAccessingCfg.GetLocalFunctionControlFlowGraphInScope(localFunction, cancellationToken);
492if (!_localFunctionTargetsToAccessingCfgMap.TryGetValue(localFunction, out var accessingCfg))
497var localFunctionCfg = accessingCfg.GetLocalFunctionControlFlowGraphInScope(localFunction, cancellationToken);
504if (!_lambdaTargetsToAccessingCfgMap.TryGetValue(lambda, out var accessingCfg))
509var lambdaCfg = accessingCfg.GetAnonymousFunctionControlFlowGraphInScope(lambda, cancellationToken);