Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/linker.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSven Boemer <sbomer@gmail.com>2022-05-31 22:55:22 +0300
committerGitHub <noreply@github.com>2022-05-31 22:55:22 +0300
commit6f57bf9ef26214f86bb5c9532a2abbdce2a12c6d (patch)
tree85ad535008b905fb5e80b4bde457fa6e07af2bc9 /src
parent79b5653ccfd0663790b4dc4efe65c1285ede73fc (diff)
Don't crash analyzer for ref-return assignment (#2810)
* Don't crash analyzer for ref-return assignment * Same for flow capture references * Adjust tests after merge * PR feedback Add issue links to tests
Diffstat (limited to 'src')
-rw-r--r--src/ILLink.RoslynAnalyzer/DataFlow/CapturedReferenceValue.cs1
-rw-r--r--src/ILLink.RoslynAnalyzer/DataFlow/LocalDataFlowVisitor.cs10
2 files changed, 11 insertions, 0 deletions
diff --git a/src/ILLink.RoslynAnalyzer/DataFlow/CapturedReferenceValue.cs b/src/ILLink.RoslynAnalyzer/DataFlow/CapturedReferenceValue.cs
index 2fbe9ad43..76c4d1e98 100644
--- a/src/ILLink.RoslynAnalyzer/DataFlow/CapturedReferenceValue.cs
+++ b/src/ILLink.RoslynAnalyzer/DataFlow/CapturedReferenceValue.cs
@@ -22,6 +22,7 @@ namespace ILLink.RoslynAnalyzer.DataFlow
break;
case OperationKind.None:
case OperationKind.InstanceReference:
+ case OperationKind.Invocation:
// These will just be ignored when referenced later.
break;
default:
diff --git a/src/ILLink.RoslynAnalyzer/DataFlow/LocalDataFlowVisitor.cs b/src/ILLink.RoslynAnalyzer/DataFlow/LocalDataFlowVisitor.cs
index a99db8a4d..4f16f1b0c 100644
--- a/src/ILLink.RoslynAnalyzer/DataFlow/LocalDataFlowVisitor.cs
+++ b/src/ILLink.RoslynAnalyzer/DataFlow/LocalDataFlowVisitor.cs
@@ -180,6 +180,16 @@ namespace ILLink.RoslynAnalyzer.DataFlow
// Assignment to 'this' is not tracked currently.
// Not relevant for trimming dataflow.
break;
+ case IInvocationOperation:
+ // This can happen for an assignment to a ref return. Skip for now.
+ // The analyzer doesn't handle refs yet. This should be fixed once the analyzer
+ // also produces warnings for ref params/locals/returns.
+ // https://github.com/dotnet/linker/issues/2632
+ // https://github.com/dotnet/linker/issues/2158
+ break;
+ // Keep these cases in sync with those in CapturedReferenceValue, for any that
+ // can show up in a flow capture reference (for example, where the right-hand side
+ // is a null-coalescing operator).
default:
// NoneOperation represents operations which are unimplemented by Roslyn
// (don't have specific I*Operation types), such as pointer dereferences.