Skip to content

Commit

Permalink
Merge pull request #3062 from dotpaul/fix
Browse files Browse the repository at this point in the history
Lazily creating CFG
  • Loading branch information
dotpaul committed Nov 23, 2019
2 parents 070f56b + f2d5870 commit 1d07ec7
Showing 1 changed file with 20 additions and 9 deletions.
Expand Up @@ -76,23 +76,24 @@ public override void Initialize(AnalysisContext context)
return;
}
ControlFlowGraph cfg = operationBlockStartContext.OperationBlocks.GetControlFlowGraph();
if (cfg == null)
{
return;
}
WellKnownTypeProvider wellKnownTypeProvider = WellKnownTypeProvider.GetOrCreate(compilation);
InterproceduralAnalysisConfiguration interproceduralAnalysisConfiguration = InterproceduralAnalysisConfiguration.Create(
options,
SupportedDiagnostics,
defaultInterproceduralAnalysisKind: InterproceduralAnalysisKind.ContextSensitive,
cancellationToken: cancellationToken);
Lazy<ControlFlowGraph> controlFlowGraphFactory = new Lazy<ControlFlowGraph>(
() => operationBlockStartContext.OperationBlocks.GetControlFlowGraph());
Lazy<PointsToAnalysisResult> pointsToFactory = new Lazy<PointsToAnalysisResult>(
() =>
{
if (controlFlowGraphFactory.Value == null)
{
return null;
}
return PointsToAnalysis.TryGetOrComputeResult(
cfg,
controlFlowGraphFactory.Value,
owningSymbol,
options,
wellKnownTypeProvider,
Expand All @@ -102,8 +103,13 @@ public override void Initialize(AnalysisContext context)
Lazy<(PointsToAnalysisResult, ValueContentAnalysisResult)> valueContentFactory = new Lazy<(PointsToAnalysisResult, ValueContentAnalysisResult)>(
() =>
{
if (controlFlowGraphFactory.Value == null)
{
return (null, null);
}
ValueContentAnalysisResult valuecontentAnalysisResult = ValueContentAnalysis.TryGetOrComputeResult(
cfg,
controlFlowGraphFactory.Value,
owningSymbol,
options,
wellKnownTypeProvider,
Expand Down Expand Up @@ -179,10 +185,15 @@ public override void Initialize(AnalysisContext context)
return;
}
if (controlFlowGraphFactory.Value == null)
{
return;
}
foreach (IOperation rootOperation in rootOperationsNeedingAnalysis)
{
TaintedDataAnalysisResult taintedDataAnalysisResult = TaintedDataAnalysis.TryGetOrComputeResult(
cfg,
controlFlowGraphFactory.Value,
operationBlockAnalysisContext.Compilation,
operationBlockAnalysisContext.OwningSymbol,
operationBlockAnalysisContext.Options,
Expand Down

0 comments on commit 1d07ec7

Please sign in to comment.