1 instantiation of ControlFlowRegion
Microsoft.CodeAnalysis (1)
Operations\ControlFlowGraphBuilder.RegionBuilder.cs (1)
337
var result = new
ControlFlowRegion
(Kind, FirstBlock.Ordinal, LastBlock.Ordinal, subRegions,
341 references to ControlFlowRegion
GenerateDocumentationAndConfigFiles (18)
src\b310f676f7308b7f\SymbolUsageAnalysis.DataFlowAnalyzer.cs (1)
177
foreach (
var
region in branch.LeavingRegions)
src\b310f676f7308b7f\SymbolUsageAnalysis.DataFlowAnalyzer.FlowGraphAnalysisData.cs (3)
376
var
outermostEnclosingRegionStartingBlock = basicBlock.EnclosingRegion;
396
ControlFlowRegion
containingTryCatchFinallyRegion = null;
397
var
currentRegion = outermostEnclosingRegionStartingBlock;
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Extensions\ControlFlowRegionExtensions.cs (1)
9
internal static bool ContainsBlock(this
ControlFlowRegion
region, int destinationOrdinal)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Extensions\OperationExtensions.cs (1)
313
var
currentRegion = block.EnclosingRegion;
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\FlowAnalysis\CustomDataFlowAnalysis.cs (12)
33
var continueDispatchAfterFinally = PooledDictionary<
ControlFlowRegion
, bool>.GetInstance();
34
var dispatchedExceptionsFromRegions = PooledHashSet<
ControlFlowRegion
>.GetInstance();
74
PooledDictionary<
ControlFlowRegion
, bool> continueDispatchAfterFinally,
75
PooledHashSet<
ControlFlowRegion
> dispatchedExceptionsFromRegions,
254
bool StepThroughFinally(
ControlFlowRegion
region, int destinationOrdinal, ref TBlockAnalysisData currentAnalysisData)
259
var
enclosing = region.EnclosingRegion;
278
bool StepThroughSingleFinally(
ControlFlowRegion
@finally, ref TBlockAnalysisData currentAnalysisData)
310
void DispatchException(
ControlFlowRegion
fromRegion)
319
var
enclosing = fromRegion.Kind == ControlFlowRegionKind.Root ? null : fromRegion.EnclosingRegion;
349
var
tryAndCatch = enclosing.EnclosingRegion;
369
void DispatchExceptionThroughCatches(
ControlFlowRegion
tryAndCatch, int startAt)
380
var
@catch = tryAndCatch.NestedRegions[i];
ILLink.RoslynAnalyzer (10)
DataFlow\ControlFlowGraphProxy.cs (10)
36
public readonly record struct RegionProxy(
ControlFlowRegion
Region) : IRegion<RegionProxy>
64
foreach (
var
region in branch.FinallyRegions)
126
private static bool TryGetTryOrCatchOrFilter(
ControlFlowRegion
? region, out RegionProxy tryOrCatchOrFilterRegion)
146
ControlFlowRegion
? region = block.Block.EnclosingRegion;
169
var
enclosingRegion = catchOrFilterOrFinallyRegion.Region.EnclosingRegion!;
178
foreach (
var
nested in enclosingRegion.NestedRegions)
191
var
region = catchOrFilterRegion.Region;
202
foreach (
var
nested in tryRegion.Region.EnclosingRegion!.NestedRegions)
204
ControlFlowRegion
? catchOrFilter = null;
212
foreach (
var
filter in nested.NestedRegions)
Microsoft.CodeAnalysis (73)
Operations\BasicBlock.cs (2)
35
ControlFlowRegion
region)
132
public
ControlFlowRegion
EnclosingRegion { get; }
Operations\ControlFlowBranch.cs (18)
18
private ImmutableArray<
ControlFlowRegion
> _lazyLeavingRegions;
19
private ImmutableArray<
ControlFlowRegion
> _lazyFinallyRegions;
20
private ImmutableArray<
ControlFlowRegion
> _lazyEnteringRegions;
58
public ImmutableArray<
ControlFlowRegion
> LeavingRegions
64
ImmutableArray<
ControlFlowRegion
> result;
68
result = ImmutableArray<
ControlFlowRegion
>.Empty;
82
private static ArrayBuilder<
ControlFlowRegion
> CollectRegions(int destinationOrdinal,
ControlFlowRegion
source)
84
var builder = ArrayBuilder<
ControlFlowRegion
>.GetInstance();
101
public ImmutableArray<
ControlFlowRegion
> EnteringRegions
107
ImmutableArray<
ControlFlowRegion
> result;
111
result = ImmutableArray<
ControlFlowRegion
>.Empty;
115
ArrayBuilder<
ControlFlowRegion
> builder = CollectRegions(Source.Ordinal, Destination.EnclosingRegion);
131
public ImmutableArray<
ControlFlowRegion
> FinallyRegions
137
ArrayBuilder<
ControlFlowRegion
>? builder = null;
138
ImmutableArray<
ControlFlowRegion
> leavingRegions = LeavingRegions;
146
builder = ArrayBuilder<
ControlFlowRegion
>.GetInstance();
154
var result = builder == null ? ImmutableArray<
ControlFlowRegion
>.Empty : builder.ToImmutableAndFree();
Operations\ControlFlowGraph.cs (8)
27
private readonly ImmutableDictionary<IMethodSymbol, (
ControlFlowRegion
region, ILocalFunctionOperation operation, int ordinal)> _localFunctionsMap;
29
private readonly ImmutableDictionary<IFlowAnonymousFunctionOperation, (
ControlFlowRegion
region, int ordinal)> _anonymousFunctionsMap;
35
ImmutableArray<BasicBlock> blocks,
ControlFlowRegion
root,
37
ImmutableDictionary<IMethodSymbol, (
ControlFlowRegion
region, ILocalFunctionOperation operation, int ordinal)> localFunctionsMap,
38
ImmutableDictionary<IFlowAnonymousFunctionOperation, (
ControlFlowRegion
region, int ordinal)> anonymousFunctionsMap)
217
public
ControlFlowRegion
Root { get; }
246
if (!_localFunctionsMap.TryGetValue(localFunction, out (
ControlFlowRegion
enclosing, ILocalFunctionOperation operation, int ordinal) info))
295
if (!_anonymousFunctionsMap.TryGetValue(anonymousFunction, out (
ControlFlowRegion
enclosing, int ordinal) info))
Operations\ControlFlowGraphBuilder.BasicBlockBuilder.cs (1)
33
public
ControlFlowRegion
? Region;
Operations\ControlFlowGraphBuilder.cs (18)
87
public static ControlFlowGraph Create(IOperation body, ControlFlowGraph? parent = null,
ControlFlowRegion
? enclosing = null, CaptureIdDispenser? captureIdDispenser = null, in Context context = default)
150
var localFunctionsMap = ImmutableDictionary.CreateBuilder<IMethodSymbol, (
ControlFlowRegion
, ILocalFunctionOperation, int)>();
151
ImmutableDictionary<IFlowAnonymousFunctionOperation, (
ControlFlowRegion
, int)>.Builder? anonymousFunctionsMapOpt = null;
155
anonymousFunctionsMapOpt = ImmutableDictionary.CreateBuilder<IFlowAnonymousFunctionOperation, (
ControlFlowRegion
, int)>();
158
ControlFlowRegion
region = root.ToImmutableRegionAndFree(blocks, localFunctions, localFunctionsMap, anonymousFunctionsMapOpt, enclosing);
169
anonymousFunctionsMapOpt?.ToImmutable() ?? ImmutableDictionary<IFlowAnonymousFunctionOperation, (
ControlFlowRegion
, int)>.Empty);
236
var continueDispatchAfterFinally = PooledDictionary<
ControlFlowRegion
, bool>.GetInstance();
237
var dispatchedExceptionsFromRegions = PooledHashSet<
ControlFlowRegion
>.GetInstance();
252
PooledDictionary<
ControlFlowRegion
, bool> continueDispatchAfterFinally,
253
PooledHashSet<
ControlFlowRegion
> dispatchedExceptionsFromRegions,
352
bool stepThroughFinally(
ControlFlowRegion
region, BasicBlockBuilder destination)
359
ControlFlowRegion
enclosing = region.EnclosingRegion;
378
bool stepThroughSingleFinally(
ControlFlowRegion
@finally)
406
void dispatchException([DisallowNull]
ControlFlowRegion
? fromRegion)
415
ControlFlowRegion
? enclosing = fromRegion.Kind == ControlFlowRegionKind.Root ? null : fromRegion.EnclosingRegion;
444
ControlFlowRegion
tryAndCatch = enclosing.EnclosingRegion;
464
void dispatchExceptionThroughCatches(
ControlFlowRegion
tryAndCatch, int startAt)
475
ControlFlowRegion
@catch = tryAndCatch.NestedRegions[i];
Operations\ControlFlowGraphBuilder.RegionBuilder.cs (19)
296
public
ControlFlowRegion
ToImmutableRegionAndFree(ArrayBuilder<BasicBlockBuilder> blocks,
298
ImmutableDictionary<IMethodSymbol, (
ControlFlowRegion
region, ILocalFunctionOperation operation, int ordinal)>.Builder localFunctionsMap,
299
ImmutableDictionary<IFlowAnonymousFunctionOperation, (
ControlFlowRegion
region, int ordinal)>.Builder? anonymousFunctionsMapOpt,
300
ControlFlowRegion
? enclosing)
317
ImmutableArray<
ControlFlowRegion
> subRegions;
321
var builder = ArrayBuilder<
ControlFlowRegion
>.GetInstance(Regions.Count);
332
subRegions = ImmutableArray<
ControlFlowRegion
>.Empty;
337
var
result = new ControlFlowRegion(Kind, FirstBlock.Ordinal, LastBlock.Ordinal, subRegions,
354
foreach (
ControlFlowRegion
region in subRegions)
383
(ImmutableDictionary<IFlowAnonymousFunctionOperation, (
ControlFlowRegion
region, int ordinal)>.Builder map,
ControlFlowRegion
region) argument = (anonymousFunctionsMapOpt, result);
399
OperationVisitor<(ImmutableDictionary<IFlowAnonymousFunctionOperation, (
ControlFlowRegion
region, int ordinal)>.Builder map,
ControlFlowRegion
region), IOperation>
405
(ImmutableDictionary<IFlowAnonymousFunctionOperation, (
ControlFlowRegion
region, int ordinal)>.Builder map,
ControlFlowRegion
region) argument)
411
internal override IOperation? VisitNoneOperation(IOperation operation, (ImmutableDictionary<IFlowAnonymousFunctionOperation, (
ControlFlowRegion
region, int ordinal)>.Builder map,
ControlFlowRegion
region) argument)
418
(ImmutableDictionary<IFlowAnonymousFunctionOperation, (
ControlFlowRegion
region, int ordinal)>.Builder map,
ControlFlowRegion
region) argument)
Operations\ControlFlowRegion.cs (7)
25
public
ControlFlowRegion
? EnclosingRegion { get; private set; }
46
public ImmutableArray<
ControlFlowRegion
> NestedRegions { get; }
64
ImmutableArray<
ControlFlowRegion
> nestedRegions,
69
ControlFlowRegion
? enclosingRegion)
84
foreach (
ControlFlowRegion
r in NestedRegions)
112
ControlFlowRegion
r = NestedRegions[i];
132
foreach (
ControlFlowRegion
r in NestedRegions)
Microsoft.CodeAnalysis.Analyzers (18)
src\b310f676f7308b7f\SymbolUsageAnalysis.DataFlowAnalyzer.cs (1)
177
foreach (
var
region in branch.LeavingRegions)
src\b310f676f7308b7f\SymbolUsageAnalysis.DataFlowAnalyzer.FlowGraphAnalysisData.cs (3)
376
var
outermostEnclosingRegionStartingBlock = basicBlock.EnclosingRegion;
396
ControlFlowRegion
containingTryCatchFinallyRegion = null;
397
var
currentRegion = outermostEnclosingRegionStartingBlock;
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Extensions\ControlFlowRegionExtensions.cs (1)
9
internal static bool ContainsBlock(this
ControlFlowRegion
region, int destinationOrdinal)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Extensions\OperationExtensions.cs (1)
313
var
currentRegion = block.EnclosingRegion;
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\FlowAnalysis\CustomDataFlowAnalysis.cs (12)
33
var continueDispatchAfterFinally = PooledDictionary<
ControlFlowRegion
, bool>.GetInstance();
34
var dispatchedExceptionsFromRegions = PooledHashSet<
ControlFlowRegion
>.GetInstance();
74
PooledDictionary<
ControlFlowRegion
, bool> continueDispatchAfterFinally,
75
PooledHashSet<
ControlFlowRegion
> dispatchedExceptionsFromRegions,
254
bool StepThroughFinally(
ControlFlowRegion
region, int destinationOrdinal, ref TBlockAnalysisData currentAnalysisData)
259
var
enclosing = region.EnclosingRegion;
278
bool StepThroughSingleFinally(
ControlFlowRegion
@finally, ref TBlockAnalysisData currentAnalysisData)
310
void DispatchException(
ControlFlowRegion
fromRegion)
319
var
enclosing = fromRegion.Kind == ControlFlowRegionKind.Root ? null : fromRegion.EnclosingRegion;
349
var
tryAndCatch = enclosing.EnclosingRegion;
369
void DispatchExceptionThroughCatches(
ControlFlowRegion
tryAndCatch, int startAt)
380
var
@catch = tryAndCatch.NestedRegions[i];
Microsoft.CodeAnalysis.AnalyzerUtilities (84)
src\b310f676f7308b7f\SymbolUsageAnalysis.DataFlowAnalyzer.cs (1)
177
foreach (
var
region in branch.LeavingRegions)
src\b310f676f7308b7f\SymbolUsageAnalysis.DataFlowAnalyzer.FlowGraphAnalysisData.cs (3)
376
var
outermostEnclosingRegionStartingBlock = basicBlock.EnclosingRegion;
396
ControlFlowRegion
containingTryCatchFinallyRegion = null;
397
var
currentRegion = outermostEnclosingRegionStartingBlock;
src\roslyn\src\RoslynAnalyzers\Utilities\FlowAnalysis\BranchWithInfo.cs (20)
17
private static readonly Func<
ControlFlowRegion
, IEnumerable<
ControlFlowRegion
>> s_getTransitiveNestedRegions = GetTransitiveNestedRegions;
30
enteringRegions: ImmutableArray<
ControlFlowRegion
>.Empty,
31
leavingRegions: ImmutableArray<
ControlFlowRegion
>.Empty,
32
finallyRegions: ImmutableArray<
ControlFlowRegion
>.Empty,
43
ImmutableArray<
ControlFlowRegion
> enteringRegions,
44
ImmutableArray<
ControlFlowRegion
> leavingRegions,
45
ImmutableArray<
ControlFlowRegion
> finallyRegions,
65
public ImmutableArray<
ControlFlowRegion
> EnteringRegions { get; }
66
public ImmutableArray<
ControlFlowRegion
> FinallyRegions { get; }
67
public ImmutableArray<
ControlFlowRegion
> LeavingRegions { get; }
79
enteringRegions: ImmutableArray<
ControlFlowRegion
>.Empty,
80
leavingRegions: ImmutableArray<
ControlFlowRegion
>.Empty,
81
finallyRegions: ImmutableArray<
ControlFlowRegion
>.Empty,
98
private static IEnumerable<
ControlFlowRegion
> GetTransitiveNestedRegions(
ControlFlowRegion
region)
102
foreach (
var
nestedRegion in region.NestedRegions)
104
foreach (
var
transitiveNestedRegion in GetTransitiveNestedRegions(nestedRegion))
111
private static IEnumerable<ILocalSymbol> ComputeLeavingRegionLocals(ImmutableArray<
ControlFlowRegion
> leavingRegions)
116
private static IEnumerable<CaptureId> ComputeLeavingRegionFlowCaptures(ImmutableArray<
ControlFlowRegion
> leavingRegions)
src\roslyn\src\RoslynAnalyzers\Utilities\FlowAnalysis\Extensions\BasicBlockExtensions.cs (13)
23
var
lastFinally = predecessorBranch.FinallyRegions[^1];
35
var
region = basicBlock.EnclosingRegion;
58
public static
ControlFlowRegion
? GetContainingRegionOfKind(this BasicBlock basicBlock, ControlFlowRegionKind regionKind)
60
var
enclosingRegion = basicBlock.EnclosingRegion;
77
public static bool IsFirstBlockOfFinally(this BasicBlock basicBlock, [NotNullWhen(returnValue: true)] out
ControlFlowRegion
? finallyRegion)
83
public static bool IsLastBlockOfFinally(this BasicBlock basicBlock, [NotNullWhen(returnValue: true)] out
ControlFlowRegion
? finallyRegion)
89
public static bool IsFirstBlockOfRegionKind(this BasicBlock basicBlock, ControlFlowRegionKind regionKind, [NotNullWhen(returnValue: true)] out
ControlFlowRegion
? region)
95
public static bool IsLastBlockOfRegionKind(this BasicBlock basicBlock, ControlFlowRegionKind regionKind, [NotNullWhen(returnValue: true)] out
ControlFlowRegion
? region)
98
private static bool IsFirstOrLastBlockOfRegionKind(this BasicBlock basicBlock, ControlFlowRegionKind regionKind, bool first, [NotNullWhen(returnValue: true)] out
ControlFlowRegion
? foundRegion)
102
var
enclosingRegion = basicBlock.EnclosingRegion;
128
if (!basicBlock.IsFirstBlockOfRegionKind(ControlFlowRegionKind.Finally, out
var
finallyRegion))
144
internal static
ControlFlowRegion
? GetInnermostRegionStartedByBlock(this BasicBlock basicBlock, ControlFlowRegionKind regionKind)
151
var
enclosingRegion = basicBlock.EnclosingRegion;
src\roslyn\src\RoslynAnalyzers\Utilities\FlowAnalysis\Extensions\ControlFlowRegionExtensions.cs (3)
11
public static bool ContainsRegionOrSelf(this
ControlFlowRegion
controlFlowRegion,
ControlFlowRegion
nestedRegion)
15
public static IEnumerable<IOperation> DescendantOperations(this
ControlFlowRegion
controlFlowRegion, ControlFlowGraph cfg)
src\roslyn\src\RoslynAnalyzers\Utilities\FlowAnalysis\Extensions\IOperationExtensions_FlowAnalysis.cs (1)
24
var
currentRegion = block.EnclosingRegion;
src\roslyn\src\RoslynAnalyzers\Utilities\FlowAnalysis\FlowAnalysis\Framework\DataFlow\DataFlowAnalysis.cs (21)
66
var catchBlockInputDataMap = PooledDictionary<
ControlFlowRegion
, TAnalysisData>.GetInstance();
190
PooledDictionary<
ControlFlowRegion
, TAnalysisData> catchBlockInputDataMap,
228
var
finallyRegion = block.GetInnermostRegionStartedByBlock(ControlFlowRegionKind.Finally);
232
var
tryRegion = finallyRegion.EnclosingRegion.NestedRegions[0];
274
ControlFlowRegion
? enclosingTryAndCatchRegion = GetEnclosingTryAndCatchRegionIfStartsHandler(block);
349
if (successorBlock.IsFirstBlockOfRegionKind(ControlFlowRegionKind.TryAndFinally, out
var
tryAndFinally))
351
var
finallyRegion = tryAndFinally.NestedRegions[1];
490
static
ControlFlowRegion
? TryGetReachableCatchRegionStartingHandler(
ControlFlowRegion
tryAndCatchRegion, BasicBlock sourceBlock)
497
var
catchRegion = tryAndCatchRegion.NestedRegions.FirstOrDefault(region => region.Kind is ControlFlowRegionKind.Catch or ControlFlowRegionKind.FilterAndHandler);
506
ControlFlowRegion
? MergeIntoCatchInputData(
ControlFlowRegion
tryAndCatchRegion, TAnalysisData dataToMerge, BasicBlock sourceBlock)
508
var
catchRegion = TryGetReachableCatchRegionStartingHandler(tryAndCatchRegion, sourceBlock);
592
static
ControlFlowRegion
? GetEnclosingTryAndCatchRegionIfStartsHandler(BasicBlock block)
654
var
firstFinally = branch.FinallyRegions[0];
674
ControlFlowRegion
finallyRegion = branch.FinallyRegions[i];
683
foreach (
var
region in branch.LeavingRegions)
694
var
catchRegion = TryGetReachableCatchRegionStartingHandler(region, sourceBlock);
699
ControlFlowRegion
finallyRegion = branch.FinallyRegions[i];
715
var
catchRegion = MergeIntoCatchInputData(region, branchData, sourceBlock);
727
void AddFinallySuccessor(
ControlFlowRegion
finallyRegion, BranchWithInfo successor)
src\roslyn\src\RoslynAnalyzers\Utilities\FlowAnalysis\FlowAnalysis\Framework\DataFlow\DataFlowOperationVisitor.cs (3)
484
if (AnalysisDataForUnhandledThrowOperations != null && block.IsLastBlockOfFinally(out
var
finallyRegion))
3795
var
tryFinallyRegion = CurrentBasicBlock.GetContainingRegionOfKind(ControlFlowRegionKind.TryAndFinally)!;
3796
var
tryRegion = tryFinallyRegion.NestedRegions[0];
src\roslyn\src\RoslynAnalyzers\Utilities\FlowAnalysis\FlowAnalysis\Framework\DataFlow\ThrownExceptionInfo.cs (5)
43
private static
ControlFlowRegion
? GetHandlerRegion(BasicBlock block, INamedTypeSymbol exceptionType)
45
var
enclosingRegion = block.EnclosingRegion;
51
foreach (
var
nestedRegion in enclosingRegion.NestedRegions.Skip(1))
83
internal
ControlFlowRegion
? HandlingCatchRegion { get; }
88
internal
ControlFlowRegion
? ContainingFinallyRegion { get; }
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Extensions\ControlFlowRegionExtensions.cs (1)
9
internal static bool ContainsBlock(this
ControlFlowRegion
region, int destinationOrdinal)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Extensions\OperationExtensions.cs (1)
313
var
currentRegion = block.EnclosingRegion;
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\FlowAnalysis\CustomDataFlowAnalysis.cs (12)
33
var continueDispatchAfterFinally = PooledDictionary<
ControlFlowRegion
, bool>.GetInstance();
34
var dispatchedExceptionsFromRegions = PooledHashSet<
ControlFlowRegion
>.GetInstance();
74
PooledDictionary<
ControlFlowRegion
, bool> continueDispatchAfterFinally,
75
PooledHashSet<
ControlFlowRegion
> dispatchedExceptionsFromRegions,
254
bool StepThroughFinally(
ControlFlowRegion
region, int destinationOrdinal, ref TBlockAnalysisData currentAnalysisData)
259
var
enclosing = region.EnclosingRegion;
278
bool StepThroughSingleFinally(
ControlFlowRegion
@finally, ref TBlockAnalysisData currentAnalysisData)
310
void DispatchException(
ControlFlowRegion
fromRegion)
319
var
enclosing = fromRegion.Kind == ControlFlowRegionKind.Root ? null : fromRegion.EnclosingRegion;
349
var
tryAndCatch = enclosing.EnclosingRegion;
369
void DispatchExceptionThroughCatches(
ControlFlowRegion
tryAndCatch, int startAt)
380
var
@catch = tryAndCatch.NestedRegions[i];
Microsoft.CodeAnalysis.CodeStyle (18)
src\b310f676f7308b7f\SymbolUsageAnalysis.DataFlowAnalyzer.cs (1)
177
foreach (
var
region in branch.LeavingRegions)
src\b310f676f7308b7f\SymbolUsageAnalysis.DataFlowAnalyzer.FlowGraphAnalysisData.cs (3)
376
var
outermostEnclosingRegionStartingBlock = basicBlock.EnclosingRegion;
396
ControlFlowRegion
containingTryCatchFinallyRegion = null;
397
var
currentRegion = outermostEnclosingRegionStartingBlock;
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Extensions\ControlFlowRegionExtensions.cs (1)
9
internal static bool ContainsBlock(this
ControlFlowRegion
region, int destinationOrdinal)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Extensions\OperationExtensions.cs (1)
313
var
currentRegion = block.EnclosingRegion;
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\FlowAnalysis\CustomDataFlowAnalysis.cs (12)
33
var continueDispatchAfterFinally = PooledDictionary<
ControlFlowRegion
, bool>.GetInstance();
34
var dispatchedExceptionsFromRegions = PooledHashSet<
ControlFlowRegion
>.GetInstance();
74
PooledDictionary<
ControlFlowRegion
, bool> continueDispatchAfterFinally,
75
PooledHashSet<
ControlFlowRegion
> dispatchedExceptionsFromRegions,
254
bool StepThroughFinally(
ControlFlowRegion
region, int destinationOrdinal, ref TBlockAnalysisData currentAnalysisData)
259
var
enclosing = region.EnclosingRegion;
278
bool StepThroughSingleFinally(
ControlFlowRegion
@finally, ref TBlockAnalysisData currentAnalysisData)
310
void DispatchException(
ControlFlowRegion
fromRegion)
319
var
enclosing = fromRegion.Kind == ControlFlowRegionKind.Root ? null : fromRegion.EnclosingRegion;
349
var
tryAndCatch = enclosing.EnclosingRegion;
369
void DispatchExceptionThroughCatches(
ControlFlowRegion
tryAndCatch, int startAt)
380
var
@catch = tryAndCatch.NestedRegions[i];
Microsoft.CodeAnalysis.NetAnalyzers (66)
src\sdk\src\Microsoft.CodeAnalysis.NetAnalyzers\src\Utilities\FlowAnalysis\BranchWithInfo.cs (20)
16
private static readonly Func<
ControlFlowRegion
, IEnumerable<
ControlFlowRegion
>> s_getTransitiveNestedRegions = GetTransitiveNestedRegions;
29
enteringRegions: ImmutableArray<
ControlFlowRegion
>.Empty,
30
leavingRegions: ImmutableArray<
ControlFlowRegion
>.Empty,
31
finallyRegions: ImmutableArray<
ControlFlowRegion
>.Empty,
42
ImmutableArray<
ControlFlowRegion
> enteringRegions,
43
ImmutableArray<
ControlFlowRegion
> leavingRegions,
44
ImmutableArray<
ControlFlowRegion
> finallyRegions,
64
public ImmutableArray<
ControlFlowRegion
> EnteringRegions { get; }
65
public ImmutableArray<
ControlFlowRegion
> FinallyRegions { get; }
66
public ImmutableArray<
ControlFlowRegion
> LeavingRegions { get; }
78
enteringRegions: ImmutableArray<
ControlFlowRegion
>.Empty,
79
leavingRegions: ImmutableArray<
ControlFlowRegion
>.Empty,
80
finallyRegions: ImmutableArray<
ControlFlowRegion
>.Empty,
97
private static IEnumerable<
ControlFlowRegion
> GetTransitiveNestedRegions(
ControlFlowRegion
region)
101
foreach (
var
nestedRegion in region.NestedRegions)
103
foreach (
var
transitiveNestedRegion in GetTransitiveNestedRegions(nestedRegion))
110
private static IEnumerable<ILocalSymbol> ComputeLeavingRegionLocals(ImmutableArray<
ControlFlowRegion
> leavingRegions)
115
private static IEnumerable<CaptureId> ComputeLeavingRegionFlowCaptures(ImmutableArray<
ControlFlowRegion
> leavingRegions)
src\sdk\src\Microsoft.CodeAnalysis.NetAnalyzers\src\Utilities\FlowAnalysis\Extensions\BasicBlockExtensions.cs (13)
22
var
lastFinally = predecessorBranch.FinallyRegions[^1];
34
var
region = basicBlock.EnclosingRegion;
76
public static
ControlFlowRegion
? GetContainingRegionOfKind(this BasicBlock basicBlock, ControlFlowRegionKind regionKind)
78
var
enclosingRegion = basicBlock.EnclosingRegion;
95
public static bool IsFirstBlockOfFinally(this BasicBlock basicBlock, [NotNullWhen(returnValue: true)] out
ControlFlowRegion
? finallyRegion)
101
public static bool IsLastBlockOfFinally(this BasicBlock basicBlock, [NotNullWhen(returnValue: true)] out
ControlFlowRegion
? finallyRegion)
107
public static bool IsFirstBlockOfRegionKind(this BasicBlock basicBlock, ControlFlowRegionKind regionKind, [NotNullWhen(returnValue: true)] out
ControlFlowRegion
? region)
113
public static bool IsLastBlockOfRegionKind(this BasicBlock basicBlock, ControlFlowRegionKind regionKind, [NotNullWhen(returnValue: true)] out
ControlFlowRegion
? region)
116
private static bool IsFirstOrLastBlockOfRegionKind(this BasicBlock basicBlock, ControlFlowRegionKind regionKind, bool first, [NotNullWhen(returnValue: true)] out
ControlFlowRegion
? foundRegion)
120
var
enclosingRegion = basicBlock.EnclosingRegion;
146
if (!basicBlock.IsFirstBlockOfRegionKind(ControlFlowRegionKind.Finally, out
var
finallyRegion))
162
internal static
ControlFlowRegion
? GetInnermostRegionStartedByBlock(this BasicBlock basicBlock, ControlFlowRegionKind regionKind)
169
var
enclosingRegion = basicBlock.EnclosingRegion;
src\sdk\src\Microsoft.CodeAnalysis.NetAnalyzers\src\Utilities\FlowAnalysis\Extensions\ControlFlowRegionExtensions.cs (3)
10
public static bool ContainsRegionOrSelf(this
ControlFlowRegion
controlFlowRegion,
ControlFlowRegion
nestedRegion)
14
public static IEnumerable<IOperation> DescendantOperations(this
ControlFlowRegion
controlFlowRegion, ControlFlowGraph cfg)
src\sdk\src\Microsoft.CodeAnalysis.NetAnalyzers\src\Utilities\FlowAnalysis\Extensions\IOperationExtensions_FlowAnalysis.cs (1)
23
var
currentRegion = block.EnclosingRegion;
src\sdk\src\Microsoft.CodeAnalysis.NetAnalyzers\src\Utilities\FlowAnalysis\FlowAnalysis\Framework\DataFlow\DataFlowAnalysis.cs (21)
64
var catchBlockInputDataMap = PooledDictionary<
ControlFlowRegion
, TAnalysisData>.GetInstance();
188
PooledDictionary<
ControlFlowRegion
, TAnalysisData> catchBlockInputDataMap,
226
var
finallyRegion = block.GetInnermostRegionStartedByBlock(ControlFlowRegionKind.Finally);
230
var
tryRegion = finallyRegion.EnclosingRegion.NestedRegions[0];
272
ControlFlowRegion
? enclosingTryAndCatchRegion = GetEnclosingTryAndCatchRegionIfStartsHandler(block);
347
if (successorBlock.IsFirstBlockOfRegionKind(ControlFlowRegionKind.TryAndFinally, out
var
tryAndFinally))
349
var
finallyRegion = tryAndFinally.NestedRegions[1];
488
static
ControlFlowRegion
? TryGetReachableCatchRegionStartingHandler(
ControlFlowRegion
tryAndCatchRegion, BasicBlock sourceBlock)
495
var
catchRegion = tryAndCatchRegion.NestedRegions.FirstOrDefault(region => region.Kind is ControlFlowRegionKind.Catch or ControlFlowRegionKind.FilterAndHandler);
504
ControlFlowRegion
? MergeIntoCatchInputData(
ControlFlowRegion
tryAndCatchRegion, TAnalysisData dataToMerge, BasicBlock sourceBlock)
506
var
catchRegion = TryGetReachableCatchRegionStartingHandler(tryAndCatchRegion, sourceBlock);
590
static
ControlFlowRegion
? GetEnclosingTryAndCatchRegionIfStartsHandler(BasicBlock block)
652
var
firstFinally = branch.FinallyRegions[0];
672
ControlFlowRegion
finallyRegion = branch.FinallyRegions[i];
681
foreach (
var
region in branch.LeavingRegions)
692
var
catchRegion = TryGetReachableCatchRegionStartingHandler(region, sourceBlock);
697
ControlFlowRegion
finallyRegion = branch.FinallyRegions[i];
713
var
catchRegion = MergeIntoCatchInputData(region, branchData, sourceBlock);
725
void AddFinallySuccessor(
ControlFlowRegion
finallyRegion, BranchWithInfo successor)
src\sdk\src\Microsoft.CodeAnalysis.NetAnalyzers\src\Utilities\FlowAnalysis\FlowAnalysis\Framework\DataFlow\DataFlowOperationVisitor.cs (3)
481
if (AnalysisDataForUnhandledThrowOperations != null && block.IsLastBlockOfFinally(out
var
finallyRegion))
3792
var
tryFinallyRegion = CurrentBasicBlock.GetContainingRegionOfKind(ControlFlowRegionKind.TryAndFinally)!;
3793
var
tryRegion = tryFinallyRegion.NestedRegions[0];
src\sdk\src\Microsoft.CodeAnalysis.NetAnalyzers\src\Utilities\FlowAnalysis\FlowAnalysis\Framework\DataFlow\ThrownExceptionInfo.cs (5)
41
private static
ControlFlowRegion
? GetHandlerRegion(BasicBlock block, INamedTypeSymbol exceptionType)
43
var
enclosingRegion = block.EnclosingRegion;
49
foreach (
var
nestedRegion in enclosingRegion.NestedRegions.Skip(1))
81
internal
ControlFlowRegion
? HandlingCatchRegion { get; }
86
internal
ControlFlowRegion
? ContainingFinallyRegion { get; }
Microsoft.CodeAnalysis.ResxSourceGenerator (18)
src\b310f676f7308b7f\SymbolUsageAnalysis.DataFlowAnalyzer.cs (1)
177
foreach (
var
region in branch.LeavingRegions)
src\b310f676f7308b7f\SymbolUsageAnalysis.DataFlowAnalyzer.FlowGraphAnalysisData.cs (3)
376
var
outermostEnclosingRegionStartingBlock = basicBlock.EnclosingRegion;
396
ControlFlowRegion
containingTryCatchFinallyRegion = null;
397
var
currentRegion = outermostEnclosingRegionStartingBlock;
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Extensions\ControlFlowRegionExtensions.cs (1)
9
internal static bool ContainsBlock(this
ControlFlowRegion
region, int destinationOrdinal)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Extensions\OperationExtensions.cs (1)
313
var
currentRegion = block.EnclosingRegion;
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\FlowAnalysis\CustomDataFlowAnalysis.cs (12)
33
var continueDispatchAfterFinally = PooledDictionary<
ControlFlowRegion
, bool>.GetInstance();
34
var dispatchedExceptionsFromRegions = PooledHashSet<
ControlFlowRegion
>.GetInstance();
74
PooledDictionary<
ControlFlowRegion
, bool> continueDispatchAfterFinally,
75
PooledHashSet<
ControlFlowRegion
> dispatchedExceptionsFromRegions,
254
bool StepThroughFinally(
ControlFlowRegion
region, int destinationOrdinal, ref TBlockAnalysisData currentAnalysisData)
259
var
enclosing = region.EnclosingRegion;
278
bool StepThroughSingleFinally(
ControlFlowRegion
@finally, ref TBlockAnalysisData currentAnalysisData)
310
void DispatchException(
ControlFlowRegion
fromRegion)
319
var
enclosing = fromRegion.Kind == ControlFlowRegionKind.Root ? null : fromRegion.EnclosingRegion;
349
var
tryAndCatch = enclosing.EnclosingRegion;
369
void DispatchExceptionThroughCatches(
ControlFlowRegion
tryAndCatch, int startAt)
380
var
@catch = tryAndCatch.NestedRegions[i];
Microsoft.CodeAnalysis.Workspaces (18)
src\b310f676f7308b7f\SymbolUsageAnalysis.DataFlowAnalyzer.cs (1)
177
foreach (
var
region in branch.LeavingRegions)
src\b310f676f7308b7f\SymbolUsageAnalysis.DataFlowAnalyzer.FlowGraphAnalysisData.cs (3)
376
var
outermostEnclosingRegionStartingBlock = basicBlock.EnclosingRegion;
396
ControlFlowRegion
containingTryCatchFinallyRegion = null;
397
var
currentRegion = outermostEnclosingRegionStartingBlock;
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Extensions\ControlFlowRegionExtensions.cs (1)
9
internal static bool ContainsBlock(this
ControlFlowRegion
region, int destinationOrdinal)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Extensions\OperationExtensions.cs (1)
313
var
currentRegion = block.EnclosingRegion;
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\FlowAnalysis\CustomDataFlowAnalysis.cs (12)
33
var continueDispatchAfterFinally = PooledDictionary<
ControlFlowRegion
, bool>.GetInstance();
34
var dispatchedExceptionsFromRegions = PooledHashSet<
ControlFlowRegion
>.GetInstance();
74
PooledDictionary<
ControlFlowRegion
, bool> continueDispatchAfterFinally,
75
PooledHashSet<
ControlFlowRegion
> dispatchedExceptionsFromRegions,
254
bool StepThroughFinally(
ControlFlowRegion
region, int destinationOrdinal, ref TBlockAnalysisData currentAnalysisData)
259
var
enclosing = region.EnclosingRegion;
278
bool StepThroughSingleFinally(
ControlFlowRegion
@finally, ref TBlockAnalysisData currentAnalysisData)
310
void DispatchException(
ControlFlowRegion
fromRegion)
319
var
enclosing = fromRegion.Kind == ControlFlowRegionKind.Root ? null : fromRegion.EnclosingRegion;
349
var
tryAndCatch = enclosing.EnclosingRegion;
369
void DispatchExceptionThroughCatches(
ControlFlowRegion
tryAndCatch, int startAt)
380
var
@catch = tryAndCatch.NestedRegions[i];
Roslyn.Diagnostics.Analyzers (18)
src\b310f676f7308b7f\SymbolUsageAnalysis.DataFlowAnalyzer.cs (1)
177
foreach (
var
region in branch.LeavingRegions)
src\b310f676f7308b7f\SymbolUsageAnalysis.DataFlowAnalyzer.FlowGraphAnalysisData.cs (3)
376
var
outermostEnclosingRegionStartingBlock = basicBlock.EnclosingRegion;
396
ControlFlowRegion
containingTryCatchFinallyRegion = null;
397
var
currentRegion = outermostEnclosingRegionStartingBlock;
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Extensions\ControlFlowRegionExtensions.cs (1)
9
internal static bool ContainsBlock(this
ControlFlowRegion
region, int destinationOrdinal)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Extensions\OperationExtensions.cs (1)
313
var
currentRegion = block.EnclosingRegion;
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\FlowAnalysis\CustomDataFlowAnalysis.cs (12)
33
var continueDispatchAfterFinally = PooledDictionary<
ControlFlowRegion
, bool>.GetInstance();
34
var dispatchedExceptionsFromRegions = PooledHashSet<
ControlFlowRegion
>.GetInstance();
74
PooledDictionary<
ControlFlowRegion
, bool> continueDispatchAfterFinally,
75
PooledHashSet<
ControlFlowRegion
> dispatchedExceptionsFromRegions,
254
bool StepThroughFinally(
ControlFlowRegion
region, int destinationOrdinal, ref TBlockAnalysisData currentAnalysisData)
259
var
enclosing = region.EnclosingRegion;
278
bool StepThroughSingleFinally(
ControlFlowRegion
@finally, ref TBlockAnalysisData currentAnalysisData)
310
void DispatchException(
ControlFlowRegion
fromRegion)
319
var
enclosing = fromRegion.Kind == ControlFlowRegionKind.Root ? null : fromRegion.EnclosingRegion;
349
var
tryAndCatch = enclosing.EnclosingRegion;
369
void DispatchExceptionThroughCatches(
ControlFlowRegion
tryAndCatch, int startAt)
380
var
@catch = tryAndCatch.NestedRegions[i];