aboutsummaryrefslogtreecommitdiffstats
path: root/src/glsl/ir.cpp
diff options
context:
space:
mode:
authorKenneth Graunke <[email protected]>2012-03-13 12:39:32 -0700
committerKenneth Graunke <[email protected]>2012-03-26 10:21:51 -0700
commit25b0d45d038774406f2bb7173abc33a3cb261db2 (patch)
treee5aaec71287d309ad559ec601986d719dd7e87f2 /src/glsl/ir.cpp
parentced54dcf9b496dbe0bf254673ecee37014c1ee3b (diff)
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 <[email protected]> Reviewed-by: Eric Anholt <[email protected]>
Diffstat (limited to 'src/glsl/ir.cpp')
-rw-r--r--src/glsl/ir.cpp19
1 files changed, 9 insertions, 10 deletions
diff --git a/src/glsl/ir.cpp b/src/glsl/ir.cpp
index a5eca5a51a0..3fc4a9857e2 100644
--- a/src/glsl/ir.cpp
+++ b/src/glsl/ir.cpp
@@ -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();
}
}