| ▲ | ngruhn 6 hours ago | |
It can be used in static analysis or type checking. E.g.
By maintaining an interval of possible values of x, you can detect the unreachable branch, because the interval becomes empty: | ||
| ▲ | Oberdiah 4 hours ago | parent | next [-] | |
I’m working on a static analyser at the moment that does this, and the inferences that can be made just from the information of intervals is quite impressive. One thing you run into pretty quickly though in a lot of languages is integer overflow ruining your day - in your example above the commented section is reachable for signed ints that support overflow and that adds a whole other layer of complexity to things. | ||
| ▲ | thekoma 4 hours ago | parent | prev [-] | |
We recently implemented this idea in an LLVM optimisation pass based on value-range information from sensor datasheets [1]. | ||