Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle unreachable code in the nullable walker #28798

Closed
gafter opened this issue Jul 23, 2018 · 3 comments
Closed

Handle unreachable code in the nullable walker #28798

gafter opened this issue Jul 23, 2018 · 3 comments

Comments

@gafter
Copy link
Member

gafter commented Jul 23, 2018

In unreachable code, the state for every trackable variable should be "not null".

There are a few reasons for this:

  1. From a formal, flow-analysis theoretical point of view, this is one end of the lattice and is therefore the default value of the state that is refined as flow analysis proceeds.
  2. From a practical point of view, this prevents producing (most) warnings in unreachable code (even if those warnings would later be suppressed).
  3. The flow analysis base classes expect the state to implement bool AbstractState.Reachable { get; }

There are a couple of approaches for doing this. The simplest is to have a bit in the state that tracks whether the state is reachable or not (just like control flow analysis and data flow analysis). When such a state is asked for the nullable state of some variable, it always answers "not null".

Another approach, which may be worth doing in addition, would be to

  1. Suppress all warnings when the state is unreachable.
  2. When merging two states, if one of them is reachable then the result state is the other one.
@gafter
Copy link
Member Author

gafter commented Mar 5, 2019

This was done in #33648

@jcouv
Copy link
Member

jcouv commented Mar 14, 2019

Re-opening as this issue is still mentioned in code/comments (probably just a matter of cleanup).

@jcouv jcouv reopened this Mar 14, 2019
@jcouv jcouv modified the milestones: 16.1, 16.2 Apr 23, 2019
@jcouv
Copy link
Member

jcouv commented May 10, 2019

I checked again and found that the remaining references to this issue have now been cleaned up. Closing

@jcouv jcouv closed this as completed May 10, 2019
@jcouv jcouv moved this to Active/Investigating in Compiler: Julien's umbrellas Jun 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

No branches or pull requests

2 participants