Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
1aa7e2cd
R
roslyn
项目概览
lwm1986
/
roslyn
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
roslyn
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
1aa7e2cd
编写于
3月 19, 2019
作者:
M
Manish Vasani
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Address review feedback
上级
3f0b73c0
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
35 addition
and
35 deletion
+35
-35
src/Test/Utilities/Portable/Compilation/FlowAnalysis/BasicBlockReachabilityDataFlowAnalyzer.cs
...on/FlowAnalysis/BasicBlockReachabilityDataFlowAnalyzer.cs
+2
-2
src/Workspaces/Core/Portable/FlowAnalysis/CustomDataFlowAnalysis.cs
...aces/Core/Portable/FlowAnalysis/CustomDataFlowAnalysis.cs
+3
-3
src/Workspaces/Core/Portable/FlowAnalysis/DataFlowAnalyzer.cs
...Workspaces/Core/Portable/FlowAnalysis/DataFlowAnalyzer.cs
+1
-1
src/Workspaces/Core/Portable/FlowAnalysis/SymbolUsageAnalysis/SymbolUsageAnalysis.DataFlowAnalyzer.FlowGraphAnalysisData.cs
...olUsageAnalysis.DataFlowAnalyzer.FlowGraphAnalysisData.cs
+21
-18
src/Workspaces/Core/Portable/FlowAnalysis/SymbolUsageAnalysis/SymbolUsageAnalysis.DataFlowAnalyzer.cs
...mbolUsageAnalysis/SymbolUsageAnalysis.DataFlowAnalyzer.cs
+7
-11
src/Workspaces/Core/Portable/FlowAnalysis/SymbolUsageAnalysis/SymbolUsageAnalysis.Walker.cs
...nalysis/SymbolUsageAnalysis/SymbolUsageAnalysis.Walker.cs
+1
-0
未找到文件。
src/Test/Utilities/Portable/Compilation/FlowAnalysis/BasicBlockReachabilityDataFlowAnalyzer.cs
浏览文件 @
1aa7e2cd
...
@@ -24,7 +24,7 @@ public static BitVector Run(ControlFlowGraph controlFlowGraph)
...
@@ -24,7 +24,7 @@ public static BitVector Run(ControlFlowGraph controlFlowGraph)
public
override
bool
AnalyzeBlock
(
BasicBlock
basicBlock
,
CancellationToken
cancellationToken
)
public
override
bool
AnalyzeBlock
(
BasicBlock
basicBlock
,
CancellationToken
cancellationToken
)
{
{
SetCurrentAnalysisData
(
basicBlock
,
isReachable
:
true
);
SetCurrentAnalysisData
(
basicBlock
,
isReachable
:
true
,
cancellationToken
);
return
true
;
return
true
;
}
}
...
@@ -54,7 +54,7 @@ public override bool AnalyzeNonConditionalBranch(BasicBlock basicBlock, bool cur
...
@@ -54,7 +54,7 @@ public override bool AnalyzeNonConditionalBranch(BasicBlock basicBlock, bool cur
return
(
currentIsReachable
,
currentIsReachable
);
return
(
currentIsReachable
,
currentIsReachable
);
}
}
public
override
void
SetCurrentAnalysisData
(
BasicBlock
basicBlock
,
bool
isReachable
)
public
override
void
SetCurrentAnalysisData
(
BasicBlock
basicBlock
,
bool
isReachable
,
CancellationToken
cancellationToken
)
{
{
_visited
[
basicBlock
.
Ordinal
]
=
isReachable
;
_visited
[
basicBlock
.
Ordinal
]
=
isReachable
;
}
}
...
...
src/Workspaces/Core/Portable/FlowAnalysis/CustomDataFlowAnalysis.cs
浏览文件 @
1aa7e2cd
...
@@ -79,7 +79,7 @@ public static TBlockAnalysisData Run(ControlFlowGraph controlFlowGraph, DataFlow
...
@@ -79,7 +79,7 @@ public static TBlockAnalysisData Run(ControlFlowGraph controlFlowGraph, DataFlow
var
toVisit
=
new
SortedSet
<
int
>();
var
toVisit
=
new
SortedSet
<
int
>();
var
firstBlock
=
blocks
[
firstBlockOrdinal
];
var
firstBlock
=
blocks
[
firstBlockOrdinal
];
analyzer
.
SetCurrentAnalysisData
(
firstBlock
,
initialAnalysisData
);
analyzer
.
SetCurrentAnalysisData
(
firstBlock
,
initialAnalysisData
,
cancellationToken
);
toVisit
.
Add
(
firstBlock
.
Ordinal
);
toVisit
.
Add
(
firstBlock
.
Ordinal
);
var
processedBlocks
=
PooledHashSet
<
BasicBlock
>.
GetInstance
();
var
processedBlocks
=
PooledHashSet
<
BasicBlock
>.
GetInstance
();
...
@@ -122,7 +122,7 @@ public static TBlockAnalysisData Run(ControlFlowGraph controlFlowGraph, DataFlow
...
@@ -122,7 +122,7 @@ public static TBlockAnalysisData Run(ControlFlowGraph controlFlowGraph, DataFlow
continue
;
continue
;
}
}
analyzer
.
SetCurrentAnalysisData
(
current
,
analyzer
.
GetEmptyAnalysisData
());
analyzer
.
SetCurrentAnalysisData
(
current
,
analyzer
.
GetEmptyAnalysisData
()
,
cancellationToken
);
}
}
if
(
current
.
Ordinal
<
firstBlockOrdinal
||
current
.
Ordinal
>
lastBlockOrdinal
)
if
(
current
.
Ordinal
<
firstBlockOrdinal
||
current
.
Ordinal
>
lastBlockOrdinal
)
...
@@ -238,7 +238,7 @@ void FollowBranch(BasicBlock current, ControlFlowBranch branch, TBlockAnalysisDa
...
@@ -238,7 +238,7 @@ void FollowBranch(BasicBlock current, ControlFlowBranch branch, TBlockAnalysisDa
if
((
current
.
IsReachable
||
!
destination
.
IsReachable
)
&&
if
((
current
.
IsReachable
||
!
destination
.
IsReachable
)
&&
(!
analyzer
.
IsEqual
(
currentDestinationData
,
mergedAnalysisData
)
||
!
processedBlocks
.
Contains
(
destination
)))
(!
analyzer
.
IsEqual
(
currentDestinationData
,
mergedAnalysisData
)
||
!
processedBlocks
.
Contains
(
destination
)))
{
{
analyzer
.
SetCurrentAnalysisData
(
destination
,
mergedAnalysisData
);
analyzer
.
SetCurrentAnalysisData
(
destination
,
mergedAnalysisData
,
cancellationToken
);
toVisit
.
Add
(
branch
.
Destination
.
Ordinal
);
toVisit
.
Add
(
branch
.
Destination
.
Ordinal
);
}
}
}
}
...
...
src/Workspaces/Core/Portable/FlowAnalysis/DataFlowAnalyzer.cs
浏览文件 @
1aa7e2cd
...
@@ -24,7 +24,7 @@ internal abstract class DataFlowAnalyzer<TBlockAnalysisData> : IDisposable
...
@@ -24,7 +24,7 @@ internal abstract class DataFlowAnalyzer<TBlockAnalysisData> : IDisposable
/// <summary>
/// <summary>
/// Updates the current analysis data for the given basic block.
/// Updates the current analysis data for the given basic block.
/// </summary>
/// </summary>
public
abstract
void
SetCurrentAnalysisData
(
BasicBlock
basicBlock
,
TBlockAnalysisData
data
);
public
abstract
void
SetCurrentAnalysisData
(
BasicBlock
basicBlock
,
TBlockAnalysisData
data
,
CancellationToken
cancellationToken
);
/// <summary>
/// <summary>
/// Analyze the given basic block and return the block analysis data at the end of the block for its successors.
/// Analyze the given basic block and return the block analysis data at the end of the block for its successors.
...
...
src/Workspaces/Core/Portable/FlowAnalysis/SymbolUsageAnalysis/SymbolUsageAnalysis.DataFlowAnalyzer.FlowGraphAnalysisData.cs
浏览文件 @
1aa7e2cd
...
@@ -156,24 +156,24 @@ private sealed class FlowGraphAnalysisData : AnalysisData
...
@@ -156,24 +156,24 @@ private sealed class FlowGraphAnalysisData : AnalysisData
public
BasicBlockAnalysisData
GetBlockAnalysisData
(
BasicBlock
basicBlock
)
public
BasicBlockAnalysisData
GetBlockAnalysisData
(
BasicBlock
basicBlock
)
=>
_analysisDataByBasicBlockMap
[
basicBlock
];
=>
_analysisDataByBasicBlockMap
[
basicBlock
];
public
BasicBlockAnalysisData
GetOrCreateBlockAnalysisData
(
BasicBlock
basicBlock
)
public
BasicBlockAnalysisData
GetOrCreateBlockAnalysisData
(
BasicBlock
basicBlock
,
CancellationToken
cancellationToken
)
{
{
if
(
_analysisDataByBasicBlockMap
[
basicBlock
]
==
null
)
if
(
_analysisDataByBasicBlockMap
[
basicBlock
]
==
null
)
{
{
_analysisDataByBasicBlockMap
[
basicBlock
]
=
CreateBlockAnalysisData
();
_analysisDataByBasicBlockMap
[
basicBlock
]
=
CreateBlockAnalysisData
();
}
}
HandleCatchOrFilterOrFinallyInitialization
(
basicBlock
);
HandleCatchOrFilterOrFinallyInitialization
(
basicBlock
,
cancellationToken
);
return
_analysisDataByBasicBlockMap
[
basicBlock
];
return
_analysisDataByBasicBlockMap
[
basicBlock
];
}
}
private
PooledHashSet
<(
ISymbol
,
IOperation
)>
GetOrCreateSymbolWritesInBlockRange
(
int
firstBlockOrdinal
,
int
lastBlockOrdinal
)
private
PooledHashSet
<(
ISymbol
,
IOperation
)>
GetOrCreateSymbolWritesInBlockRange
(
int
firstBlockOrdinal
,
int
lastBlockOrdinal
,
CancellationToken
cancellationToken
)
{
{
if
(!
_symbolWritesInsideBlockRangeMap
.
TryGetValue
((
firstBlockOrdinal
,
lastBlockOrdinal
),
out
var
writesInBlockRange
))
if
(!
_symbolWritesInsideBlockRangeMap
.
TryGetValue
((
firstBlockOrdinal
,
lastBlockOrdinal
),
out
var
writesInBlockRange
))
{
{
// Compute all descendant operations in basic block range.
// Compute all descendant operations in basic block range.
var
operations
=
PooledHashSet
<
IOperation
>.
GetInstance
();
var
operations
=
PooledHashSet
<
IOperation
>.
GetInstance
();
Add
OperationsInRange
(
ControlFlowGraph
,
firstBlockOrdinal
,
lastBlockOrdinal
,
operations
);
Add
DescendantOperationsInRange
(
ControlFlowGraph
,
firstBlockOrdinal
,
lastBlockOrdinal
,
operations
,
cancellationToken
);
// Filter down the operations to writes within this block range.
// Filter down the operations to writes within this block range.
writesInBlockRange
=
PooledHashSet
<(
ISymbol
,
IOperation
)>.
GetInstance
();
writesInBlockRange
=
PooledHashSet
<(
ISymbol
,
IOperation
)>.
GetInstance
();
...
@@ -189,15 +189,17 @@ private PooledHashSet<(ISymbol, IOperation)> GetOrCreateSymbolWritesInBlockRange
...
@@ -189,15 +189,17 @@ private PooledHashSet<(ISymbol, IOperation)> GetOrCreateSymbolWritesInBlockRange
return
writesInBlockRange
;
return
writesInBlockRange
;
}
}
private
void
AddOperationsInRange
(
private
void
Add
Descendant
OperationsInRange
(
ControlFlowGraph
cfg
,
ControlFlowGraph
cfg
,
int
firstBlockOrdinal
,
int
firstBlockOrdinal
,
int
lastBlockOrdinal
,
int
lastBlockOrdinal
,
PooledHashSet
<
IOperation
>
operationsBuilder
)
PooledHashSet
<
IOperation
>
operationsBuilder
,
CancellationToken
cancellationToken
)
{
{
// Compute all descendant operations in basic block range.
// Compute all descendant operations in basic block range.
for
(
int
i
=
firstBlockOrdinal
;
i
<=
lastBlockOrdinal
;
i
++)
for
(
int
i
=
firstBlockOrdinal
;
i
<=
lastBlockOrdinal
;
i
++)
{
{
cancellationToken
.
ThrowIfCancellationRequested
();
foreach
(
var
operation
in
cfg
.
Blocks
[
i
].
DescendantOperations
())
foreach
(
var
operation
in
cfg
.
Blocks
[
i
].
DescendantOperations
())
{
{
var
added
=
operationsBuilder
.
Add
(
operation
);
var
added
=
operationsBuilder
.
Add
(
operation
);
...
@@ -206,14 +208,14 @@ private PooledHashSet<(ISymbol, IOperation)> GetOrCreateSymbolWritesInBlockRange
...
@@ -206,14 +208,14 @@ private PooledHashSet<(ISymbol, IOperation)> GetOrCreateSymbolWritesInBlockRange
if
(
invocation
.
Instance
!=
null
&&
if
(
invocation
.
Instance
!=
null
&&
_reachingDelegateCreationTargets
.
TryGetValue
(
invocation
.
Instance
,
out
var
targets
))
_reachingDelegateCreationTargets
.
TryGetValue
(
invocation
.
Instance
,
out
var
targets
))
{
{
AddOperationsFromDelegateCreationTargets
(
targets
);
Add
Descendant
OperationsFromDelegateCreationTargets
(
targets
);
}
}
else
if
(
invocation
.
TargetMethod
.
IsLocalFunction
())
else
if
(
invocation
.
TargetMethod
.
IsLocalFunction
())
{
{
var
localFunctionGraph
=
cfg
.
GetLocalFunctionControlFlowGraphInScope
(
invocation
.
TargetMethod
);
var
localFunctionGraph
=
cfg
.
GetLocalFunctionControlFlowGraphInScope
(
invocation
.
TargetMethod
);
if
(
localFunctionGraph
!=
null
)
if
(
localFunctionGraph
!=
null
)
{
{
AddOperationsInLambdaOrLocalFunctionGraph
(
localFunctionGraph
);
Add
Descendant
OperationsInLambdaOrLocalFunctionGraph
(
localFunctionGraph
);
}
}
}
}
}
}
...
@@ -223,7 +225,7 @@ private PooledHashSet<(ISymbol, IOperation)> GetOrCreateSymbolWritesInBlockRange
...
@@ -223,7 +225,7 @@ private PooledHashSet<(ISymbol, IOperation)> GetOrCreateSymbolWritesInBlockRange
return
;
return
;
// Local functions.
// Local functions.
void
AddOperationsFromDelegateCreationTargets
(
PooledHashSet
<
IOperation
>
targets
)
void
Add
Descendant
OperationsFromDelegateCreationTargets
(
PooledHashSet
<
IOperation
>
targets
)
{
{
foreach
(
var
target
in
targets
)
foreach
(
var
target
in
targets
)
{
{
...
@@ -246,15 +248,16 @@ void AddOperationsFromDelegateCreationTargets(PooledHashSet<IOperation> targets)
...
@@ -246,15 +248,16 @@ void AddOperationsFromDelegateCreationTargets(PooledHashSet<IOperation> targets)
if
(
lambdaOrLocalFunctionCfgOpt
!=
null
&&
if
(
lambdaOrLocalFunctionCfgOpt
!=
null
&&
operationsBuilder
.
Add
(
target
))
operationsBuilder
.
Add
(
target
))
{
{
AddOperationsInLambdaOrLocalFunctionGraph
(
lambdaOrLocalFunctionCfgOpt
);
Add
Descendant
OperationsInLambdaOrLocalFunctionGraph
(
lambdaOrLocalFunctionCfgOpt
);
}
}
}
}
}
}
void
AddOperationsInLambdaOrLocalFunctionGraph
(
ControlFlowGraph
lambdaOrLocalFunctionCfg
)
void
Add
Descendant
OperationsInLambdaOrLocalFunctionGraph
(
ControlFlowGraph
lambdaOrLocalFunctionCfg
)
{
{
Debug
.
Assert
(
lambdaOrLocalFunctionCfg
!=
null
);
Debug
.
Assert
(
lambdaOrLocalFunctionCfg
!=
null
);
AddOperationsInRange
(
lambdaOrLocalFunctionCfg
,
firstBlockOrdinal
:
0
,
lastBlockOrdinal
:
lambdaOrLocalFunctionCfg
.
Blocks
.
Length
-
1
,
operationsBuilder
);
AddDescendantOperationsInRange
(
lambdaOrLocalFunctionCfg
,
firstBlockOrdinal
:
0
,
lastBlockOrdinal
:
lambdaOrLocalFunctionCfg
.
Blocks
.
Length
-
1
,
operationsBuilder
,
cancellationToken
);
}
}
ControlFlowGraph
TryGetAnonymousFunctionControlFlowGraphInScope
(
IFlowAnonymousFunctionOperation
flowAnonymousFunctionOperation
)
ControlFlowGraph
TryGetAnonymousFunctionControlFlowGraphInScope
(
IFlowAnonymousFunctionOperation
flowAnonymousFunctionOperation
)
...
@@ -289,7 +292,7 @@ ControlFlowGraph TryGetLocalFunctionControlFlowGraphInScope(IMethodSymbol localF
...
@@ -289,7 +292,7 @@ ControlFlowGraph TryGetLocalFunctionControlFlowGraphInScope(IMethodSymbol localF
/// catch/filter/finally region.
/// catch/filter/finally region.
/// </summary>
/// </summary>
/// <param name="basicBlock"></param>
/// <param name="basicBlock"></param>
private
void
HandleCatchOrFilterOrFinallyInitialization
(
BasicBlock
basicBlock
)
private
void
HandleCatchOrFilterOrFinallyInitialization
(
BasicBlock
basicBlock
,
CancellationToken
cancellationToken
)
{
{
Debug
.
Assert
(
_analysisDataByBasicBlockMap
[
basicBlock
]
!=
null
);
Debug
.
Assert
(
_analysisDataByBasicBlockMap
[
basicBlock
]
!=
null
);
...
@@ -347,7 +350,7 @@ private void HandleCatchOrFilterOrFinallyInitialization(BasicBlock basicBlock)
...
@@ -347,7 +350,7 @@ private void HandleCatchOrFilterOrFinallyInitialization(BasicBlock basicBlock)
mergedAnalysisData
.
SetAnalysisDataFrom
(
GetBlockAnalysisData
(
firstBasicBlockInOutermostRegion
));
mergedAnalysisData
.
SetAnalysisDataFrom
(
GetBlockAnalysisData
(
firstBasicBlockInOutermostRegion
));
// All symbol writes within the try region are considered reachable at start of catch/finally region.
// All symbol writes within the try region are considered reachable at start of catch/finally region.
foreach
(
var
(
symbol
,
write
)
in
GetOrCreateSymbolWritesInBlockRange
(
containingTryCatchFinallyRegion
.
FirstBlockOrdinal
,
basicBlock
.
Ordinal
-
1
))
foreach
(
var
(
symbol
,
write
)
in
GetOrCreateSymbolWritesInBlockRange
(
containingTryCatchFinallyRegion
.
FirstBlockOrdinal
,
basicBlock
.
Ordinal
-
1
,
cancellationToken
))
{
{
mergedAnalysisData
.
OnWriteReferenceFound
(
symbol
,
write
,
maybeWritten
:
true
);
mergedAnalysisData
.
OnWriteReferenceFound
(
symbol
,
write
,
maybeWritten
:
true
);
SymbolsWriteBuilder
[(
symbol
,
write
)]
=
true
;
SymbolsWriteBuilder
[(
symbol
,
write
)]
=
true
;
...
@@ -357,8 +360,8 @@ private void HandleCatchOrFilterOrFinallyInitialization(BasicBlock basicBlock)
...
@@ -357,8 +360,8 @@ private void HandleCatchOrFilterOrFinallyInitialization(BasicBlock basicBlock)
SetBlockAnalysisData
(
basicBlock
,
mergedAnalysisData
);
SetBlockAnalysisData
(
basicBlock
,
mergedAnalysisData
);
}
}
public
void
SetCurrentBlockAnalysisDataFrom
(
BasicBlock
basicBlock
)
public
void
SetCurrentBlockAnalysisDataFrom
(
BasicBlock
basicBlock
,
CancellationToken
cancellationToken
)
=>
SetCurrentBlockAnalysisDataFrom
(
GetOrCreateBlockAnalysisData
(
basicBlock
));
=>
SetCurrentBlockAnalysisDataFrom
(
GetOrCreateBlockAnalysisData
(
basicBlock
,
cancellationToken
));
public
void
SetAnalysisDataOnEntryBlockStart
()
public
void
SetAnalysisDataOnEntryBlockStart
()
{
{
...
@@ -372,8 +375,8 @@ public void SetAnalysisDataOnEntryBlockStart()
...
@@ -372,8 +375,8 @@ public void SetAnalysisDataOnEntryBlockStart()
public
void
SetBlockAnalysisData
(
BasicBlock
basicBlock
,
BasicBlockAnalysisData
data
)
public
void
SetBlockAnalysisData
(
BasicBlock
basicBlock
,
BasicBlockAnalysisData
data
)
=>
_analysisDataByBasicBlockMap
[
basicBlock
]
=
data
;
=>
_analysisDataByBasicBlockMap
[
basicBlock
]
=
data
;
public
void
SetBlockAnalysisDataFrom
(
BasicBlock
basicBlock
,
BasicBlockAnalysisData
data
)
public
void
SetBlockAnalysisDataFrom
(
BasicBlock
basicBlock
,
BasicBlockAnalysisData
data
,
CancellationToken
cancellationToken
)
=>
GetOrCreateBlockAnalysisData
(
basicBlock
).
SetAnalysisDataFrom
(
data
);
=>
GetOrCreateBlockAnalysisData
(
basicBlock
,
cancellationToken
).
SetAnalysisDataFrom
(
data
);
public
void
SetAnalysisDataOnExitBlockEnd
()
public
void
SetAnalysisDataOnExitBlockEnd
()
{
{
...
...
src/Workspaces/Core/Portable/FlowAnalysis/SymbolUsageAnalysis/SymbolUsageAnalysis.DataFlowAnalyzer.cs
浏览文件 @
1aa7e2cd
...
@@ -17,22 +17,18 @@ internal static partial class SymbolUsageAnalysis
...
@@ -17,22 +17,18 @@ internal static partial class SymbolUsageAnalysis
private
sealed
partial
class
DataFlowAnalyzer
:
DataFlowAnalyzer
<
BasicBlockAnalysisData
>
private
sealed
partial
class
DataFlowAnalyzer
:
DataFlowAnalyzer
<
BasicBlockAnalysisData
>
{
{
private
readonly
FlowGraphAnalysisData
_analysisData
;
private
readonly
FlowGraphAnalysisData
_analysisData
;
private
readonly
CancellationToken
_cancellationToken
;
private
DataFlowAnalyzer
(
ControlFlowGraph
cfg
,
ISymbol
owningSymbol
,
CancellationToken
cancellationToken
)
private
DataFlowAnalyzer
(
ControlFlowGraph
cfg
,
ISymbol
owningSymbol
)
{
{
_analysisData
=
FlowGraphAnalysisData
.
Create
(
cfg
,
owningSymbol
,
AnalyzeLocalFunctionOrLambdaInvocation
);
_analysisData
=
FlowGraphAnalysisData
.
Create
(
cfg
,
owningSymbol
,
AnalyzeLocalFunctionOrLambdaInvocation
);
_cancellationToken
=
cancellationToken
;
}
}
private
DataFlowAnalyzer
(
private
DataFlowAnalyzer
(
ControlFlowGraph
cfg
,
ControlFlowGraph
cfg
,
IMethodSymbol
lambdaOrLocalFunction
,
IMethodSymbol
lambdaOrLocalFunction
,
FlowGraphAnalysisData
parentAnalysisData
,
FlowGraphAnalysisData
parentAnalysisData
)
CancellationToken
cancellationToken
)
{
{
_analysisData
=
FlowGraphAnalysisData
.
Create
(
cfg
,
lambdaOrLocalFunction
,
parentAnalysisData
);
_analysisData
=
FlowGraphAnalysisData
.
Create
(
cfg
,
lambdaOrLocalFunction
,
parentAnalysisData
);
_cancellationToken
=
cancellationToken
;
var
entryBlockAnalysisData
=
GetEmptyAnalysisData
();
var
entryBlockAnalysisData
=
GetEmptyAnalysisData
();
entryBlockAnalysisData
.
SetAnalysisDataFrom
(
parentAnalysisData
.
CurrentBlockAnalysisData
);
entryBlockAnalysisData
.
SetAnalysisDataFrom
(
parentAnalysisData
.
CurrentBlockAnalysisData
);
...
@@ -42,7 +38,7 @@ private DataFlowAnalyzer(ControlFlowGraph cfg, ISymbol owningSymbol, Cancellatio
...
@@ -42,7 +38,7 @@ private DataFlowAnalyzer(ControlFlowGraph cfg, ISymbol owningSymbol, Cancellatio
public
static
SymbolUsageResult
RunAnalysis
(
ControlFlowGraph
cfg
,
ISymbol
owningSymbol
,
CancellationToken
cancellationToken
)
public
static
SymbolUsageResult
RunAnalysis
(
ControlFlowGraph
cfg
,
ISymbol
owningSymbol
,
CancellationToken
cancellationToken
)
{
{
cancellationToken
.
ThrowIfCancellationRequested
();
cancellationToken
.
ThrowIfCancellationRequested
();
using
(
var
analyzer
=
new
DataFlowAnalyzer
(
cfg
,
owningSymbol
,
cancellationToken
))
using
(
var
analyzer
=
new
DataFlowAnalyzer
(
cfg
,
owningSymbol
))
{
{
_
=
CustomDataFlowAnalysis
<
BasicBlockAnalysisData
>.
Run
(
cfg
,
analyzer
,
cancellationToken
);
_
=
CustomDataFlowAnalysis
<
BasicBlockAnalysisData
>.
Run
(
cfg
,
analyzer
,
cancellationToken
);
return
analyzer
.
_analysisData
.
ToResult
();
return
analyzer
.
_analysisData
.
ToResult
();
...
@@ -61,7 +57,7 @@ public override void Dispose()
...
@@ -61,7 +57,7 @@ public override void Dispose()
Debug
.
Assert
(
localFunctionOrLambda
.
IsLocalFunction
()
||
localFunctionOrLambda
.
IsAnonymousFunction
());
Debug
.
Assert
(
localFunctionOrLambda
.
IsLocalFunction
()
||
localFunctionOrLambda
.
IsAnonymousFunction
());
cancellationToken
.
ThrowIfCancellationRequested
();
cancellationToken
.
ThrowIfCancellationRequested
();
using
(
var
analyzer
=
new
DataFlowAnalyzer
(
cfg
,
localFunctionOrLambda
,
(
FlowGraphAnalysisData
)
parentAnalysisData
,
cancellationToken
))
using
(
var
analyzer
=
new
DataFlowAnalyzer
(
cfg
,
localFunctionOrLambda
,
(
FlowGraphAnalysisData
)
parentAnalysisData
))
{
{
var
resultBlockAnalysisData
=
CustomDataFlowAnalysis
<
BasicBlockAnalysisData
>.
Run
(
cfg
,
analyzer
,
cancellationToken
);
var
resultBlockAnalysisData
=
CustomDataFlowAnalysis
<
BasicBlockAnalysisData
>.
Run
(
cfg
,
analyzer
,
cancellationToken
);
if
(
resultBlockAnalysisData
==
null
)
if
(
resultBlockAnalysisData
==
null
)
...
@@ -101,7 +97,7 @@ public override BasicBlockAnalysisData AnalyzeBlock(BasicBlock basicBlock, Cance
...
@@ -101,7 +97,7 @@ public override BasicBlockAnalysisData AnalyzeBlock(BasicBlock basicBlock, Cance
void
BeforeBlockAnalysis
()
void
BeforeBlockAnalysis
()
{
{
// Initialize current block analysis data.
// Initialize current block analysis data.
_analysisData
.
SetCurrentBlockAnalysisDataFrom
(
basicBlock
);
_analysisData
.
SetCurrentBlockAnalysisDataFrom
(
basicBlock
,
cancellationToken
);
// At start of entry block, handle parameter definitions from method declaration.
// At start of entry block, handle parameter definitions from method declaration.
if
(
basicBlock
.
Kind
==
BasicBlockKind
.
Entry
)
if
(
basicBlock
.
Kind
==
BasicBlockKind
.
Entry
)
...
@@ -155,8 +151,8 @@ public override BasicBlockAnalysisData GetCurrentAnalysisData(BasicBlock basicBl
...
@@ -155,8 +151,8 @@ public override BasicBlockAnalysisData GetCurrentAnalysisData(BasicBlock basicBl
public
override
BasicBlockAnalysisData
GetEmptyAnalysisData
()
public
override
BasicBlockAnalysisData
GetEmptyAnalysisData
()
=>
_analysisData
.
CreateBlockAnalysisData
();
=>
_analysisData
.
CreateBlockAnalysisData
();
public
override
void
SetCurrentAnalysisData
(
BasicBlock
basicBlock
,
BasicBlockAnalysisData
data
)
public
override
void
SetCurrentAnalysisData
(
BasicBlock
basicBlock
,
BasicBlockAnalysisData
data
,
CancellationToken
cancellationToken
)
=>
_analysisData
.
SetBlockAnalysisDataFrom
(
basicBlock
,
data
);
=>
_analysisData
.
SetBlockAnalysisDataFrom
(
basicBlock
,
data
,
cancellationToken
);
public
override
bool
IsEqual
(
BasicBlockAnalysisData
analysisData1
,
BasicBlockAnalysisData
analysisData2
)
public
override
bool
IsEqual
(
BasicBlockAnalysisData
analysisData1
,
BasicBlockAnalysisData
analysisData2
)
=>
analysisData1
==
null
?
analysisData2
==
null
:
analysisData1
.
Equals
(
analysisData2
);
=>
analysisData1
==
null
?
analysisData2
==
null
:
analysisData1
.
Equals
(
analysisData2
);
...
...
src/Workspaces/Core/Portable/FlowAnalysis/SymbolUsageAnalysis/SymbolUsageAnalysis.Walker.cs
浏览文件 @
1aa7e2cd
...
@@ -173,6 +173,7 @@ private bool MakePendingWrite(IOperation operation, ISymbol symbolOpt)
...
@@ -173,6 +173,7 @@ private bool MakePendingWrite(IOperation operation, ISymbol symbolOpt)
return
false
;
return
false
;
}
}
private
void
ProcessPendingWritesForAssignmentTarget
(
IAssignmentOperation
operation
)
private
void
ProcessPendingWritesForAssignmentTarget
(
IAssignmentOperation
operation
)
{
{
if
(
_pendingWritesMap
.
TryGetValue
(
operation
,
out
var
pendingWrites
))
if
(
_pendingWritesMap
.
TryGetValue
(
operation
,
out
var
pendingWrites
))
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录