Skip to content

Commit

Permalink
fix tests and check if captureId exists in the dictionary
Browse files Browse the repository at this point in the history
  • Loading branch information
mary-georgiou-sonarsource committed Jun 19, 2024
1 parent d4a526c commit fe97fcd
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -222,13 +222,15 @@ public void ProcessBlock(ControlFlowGraph cfg, BasicBlock block)
foreach (var op in block.OperationsAndBranchValue.ToReversedExecutionOrder())
{
var operation = op.Instance;
if (IFlowCaptureOperationWrapper.IsInstance(operation))
if (IFlowCaptureOperationWrapper.IsInstance(operation)
&& FlowCaptureOperations.TryGetValue(IFlowCaptureOperationWrapper.FromOperation(operation).Id, out var captureOperations))
{
FlowCaptureOperations[IFlowCaptureOperationWrapper.FromOperation(operation).Id].ForEach(x => ProcessOperation(cfg, x));
captureOperations.ForEach(x => ProcessOperation(cfg, x));
}
else if (IFlowCaptureReferenceOperationWrapper.IsInstance(operation))
else if (IFlowCaptureReferenceOperationWrapper.IsInstance(operation)
&& FlowCaptureOperations.TryGetValue(IFlowCaptureReferenceOperationWrapper.FromOperation(operation).Id, out captureOperations))
{
FlowCaptureOperations[IFlowCaptureReferenceOperationWrapper.FromOperation(operation).Id].ForEach(x => ProcessOperation(cfg, x));
captureOperations.ForEach(x => ProcessOperation(cfg, x));
}
else
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,8 +256,8 @@ int LocalFunction(int arg)
var context = CreateContextCS(code, "LocalFunction");
context.ValidateEntry(LiveIn("arg"), LiveOut("arg"));
context.Validate("variable", LiveIn("arg"), LiveOut("arg"));
context.Validate("LocalFunction(arg - 1)", LiveIn("arg"));
context.Validate("0");
context.Validate("LocalFunction(arg - 1)", LiveIn("arg"), LiveOut("arg"));
context.Validate("0", LiveIn("arg"), LiveOut("arg"));
}

[TestMethod]
Expand Down

0 comments on commit fe97fcd

Please sign in to comment.