mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-25 00:00:11 +01:00
glsl: Make ir_dereference_array constructor assert the variable exists.
Providing a NULL pointer to the ir_dereference_array() constructor seems like a bad idea. Currently, if provided NULL, it returns a partially constructed value of error type. However, none of the callers are prepared to handle that scenario. Code inspection shows that all callers do one of the following: - Already NULL-check the argument prior to creating the dereference - Already deference the argument (and thus would crash if it were NULL) - Newly allocate the argument. Thus, it should be safe to simply assert the value passed is not NULL. This should also catch issues right away, rather than dying later. Signed-off-by: Kenneth Graunke <kenneth@whitecape.org> Reviewed-by: Eric Anholt <eric@anholt.net>
This commit is contained in:
parent
ced54dcf9b
commit
25b0d45d03
1 changed files with 9 additions and 10 deletions
|
|
@ -1055,19 +1055,18 @@ ir_dereference_array::ir_dereference_array(ir_variable *var,
|
|||
void
|
||||
ir_dereference_array::set_array(ir_rvalue *value)
|
||||
{
|
||||
assert(value != NULL);
|
||||
|
||||
this->array = value;
|
||||
this->type = glsl_type::error_type;
|
||||
|
||||
if (this->array != NULL) {
|
||||
const glsl_type *const vt = this->array->type;
|
||||
const glsl_type *const vt = this->array->type;
|
||||
|
||||
if (vt->is_array()) {
|
||||
type = vt->element_type();
|
||||
} else if (vt->is_matrix()) {
|
||||
type = vt->column_type();
|
||||
} else if (vt->is_vector()) {
|
||||
type = vt->get_base_type();
|
||||
}
|
||||
if (vt->is_array()) {
|
||||
type = vt->element_type();
|
||||
} else if (vt->is_matrix()) {
|
||||
type = vt->column_type();
|
||||
} else if (vt->is_vector()) {
|
||||
type = vt->get_base_type();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue