dotnet / roslyn

The Roslyn .NET compiler provides C# and Visual Basic languages with rich code analysis APIs.
https://docs.microsoft.com/dotnet/csharp/roslyn-sdk/
MIT License
19.08k stars 4.04k forks source link

IFlowCaptureReference and IFlowCaptureReferenceOperation should indicate if it captures/references an r-value or an l-value #31007

Open mavasani opened 6 years ago

mavasani commented 6 years ago

Currently, flow captures can capture both an lvalue and an rvalue of an operation. In the former case, a flow capture reference will always be assigned to in the control flow graph, and indicates a write to the lvalue captured by the flow capture. Dataflow analysis clients need this information about captures to decide when a value is being read versus written in a flow graph. The only way they can currently do so is doing a pass over the entire flow graph and identify flow capture references which are always assignment targets, indicating these are lvalue captures. We should instead expose this information on the IFlowXXXOperations.

mavasani commented 5 years ago

Seems that there are also cases where flow capture is being used to capture both an l-value and an r-value, for example see flow capture 0 for target of compound OR operator in CompoundAssignment_07