`range_of_expr` Handles No Context Without Crashing
Fixes a crash in `range_of_expr` when called without a statement context, ensuring global value ranges are properly returned.
The range_of_expr function in GCC, which is responsible for determining the range of possible values for an expression, was crashing when called without a statement context. This commit fixes the crash by handling the case where no statement context is provided, ensuring that the function returns a global value range as intended.
In Details
This commit fixes a bug in gimple-range-cache.cc where ranger_cache::range_of_expr would crash if called with a NULL statement, preventing it from returning the global value range. The fix adds a check for a NULL statement to handle this case.
For Context
In GCC, the range analysis tries to determine the possible values that each variable or expression can take at different points in the program. The range_of_expr function is part of this analysis, and sometimes needs to determine a value range even when there's no specific statement to look at. This commit fixes a bug that caused a crash in these situations, making the analysis more robust.