[Mesa-dev] [PATCH 2/2] glsl: Prefer unreachable("condition") over assert(!"condition")
Carl Worth
cworth at cworth.org
Fri Dec 5 13:17:12 PST 2014
The unreachable macro has the advantage (for modern compilers) of
hinting to the compiler that this code is actually unreachable, which
can help reduce spurious warnings, etc.
Also, this version is a bit easier to type correctly and understand
when reading without that seemingly out-of-place logical negation.
These were all found with the following:
git grep 'assert(! *"' -- src/glsl
and then replaced automatically.
---
I did this only for for the glsl directory for now. There are still many more
of these throughout mesa's source tree, but it felt like it would be far too
invasive to make a change like this globally.
So most of the changes here are in the glsl_types.cpp file where I was already
working, and then there are just small numbers in many of the files in the
same directory.
src/glsl/ast_function.cpp | 4 +--
src/glsl/ast_to_hir.cpp | 8 ++---
src/glsl/glcpp/glcpp-parse.y | 2 +-
src/glsl/glsl_parser_extras.cpp | 4 +--
src/glsl/glsl_symbol_table.cpp | 4 +--
src/glsl/glsl_types.cpp | 14 ++++-----
src/glsl/ir.cpp | 38 ++++++++++++------------
src/glsl/ir.h | 2 +-
src/glsl/ir_clone.cpp | 2 +-
src/glsl/ir_constant_expression.cpp | 8 ++---
src/glsl/ir_equals.cpp | 2 +-
src/glsl/ir_set_program_inouts.cpp | 2 +-
src/glsl/ir_validate.cpp | 2 +-
src/glsl/ir_visitor.h | 2 +-
src/glsl/link_interface_blocks.cpp | 2 +-
src/glsl/link_uniform_block_active_visitor.cpp | 2 +-
src/glsl/link_uniform_blocks.cpp | 2 +-
src/glsl/link_uniform_initializers.cpp | 4 +--
src/glsl/link_uniforms.cpp | 2 +-
src/glsl/link_varyings.cpp | 4 +--
src/glsl/loop_analysis.cpp | 2 +-
src/glsl/loop_controls.cpp | 2 +-
src/glsl/lower_packed_varyings.cpp | 4 +--
src/glsl/lower_packing_builtins.cpp | 2 +-
src/glsl/lower_ubo_reference.cpp | 6 ++--
src/glsl/lower_variable_index_to_cond_assign.cpp | 2 +-
src/glsl/lower_vector.cpp | 2 +-
src/glsl/opt_constant_propagation.cpp | 4 +--
src/glsl/opt_minmax.cpp | 2 +-
29 files changed, 68 insertions(+), 68 deletions(-)
diff --git a/src/glsl/ast_function.cpp b/src/glsl/ast_function.cpp
index cbff9d8..60a5414 100644
--- a/src/glsl/ast_function.cpp
+++ b/src/glsl/ast_function.cpp
@@ -661,7 +661,7 @@ dereference_component(ir_rvalue *src, unsigned component)
return dereference_component(col, r);
}
- assert(!"Should not get here.");
+ unreachable("Should not get here.");
return NULL;
}
@@ -1016,7 +1016,7 @@ emit_inline_vector_constructor(const glsl_type *type,
data.b[i + base_component] = c->get_bool_component(i);
break;
default:
- assert(!"Should not get here.");
+ unreachable("Should not get here.");
break;
}
}
diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp
index 811a955..ae68142 100644
--- a/src/glsl/ast_to_hir.cpp
+++ b/src/glsl/ast_to_hir.cpp
@@ -1193,7 +1193,7 @@ ast_expression::do_hir(exec_list *instructions,
switch (this->oper) {
case ast_aggregate:
- assert(!"ast_aggregate: Should never get here.");
+ unreachable("ast_aggregate: Should never get here.");
break;
case ast_assign: {
@@ -2314,7 +2314,7 @@ validate_explicit_location(const struct ast_type_qualifier *qual,
: (qual->location + VARYING_SLOT_VAR0);
break;
case MESA_SHADER_COMPUTE:
- assert(!"Unexpected shader type");
+ unreachable("Unexpected shader type");
break;
}
} else {
@@ -5412,7 +5412,7 @@ ast_interface_block::hir(exec_list *instructions,
} else {
var_mode = ir_var_auto;
iface_type_name = "UNKNOWN";
- assert(!"interface block layout qualifier not found!");
+ unreachable("interface block layout qualifier not found!");
}
enum glsl_matrix_layout matrix_layout = GLSL_MATRIX_LAYOUT_INHERITED;
@@ -6008,7 +6008,7 @@ remove_per_vertex_blocks(exec_list *instructions,
}
break;
default:
- assert(!"Unexpected mode");
+ unreachable("Unexpected mode");
break;
}
diff --git a/src/glsl/glcpp/glcpp-parse.y b/src/glsl/glcpp/glcpp-parse.y
index f1119eb..f1c006e 100644
--- a/src/glsl/glcpp/glcpp-parse.y
+++ b/src/glsl/glcpp/glcpp-parse.y
@@ -1169,7 +1169,7 @@ _token_print (char **out, size_t *len, token_t *token)
/* Nothing to print. */
break;
default:
- assert(!"Error: Don't know how to print token.");
+ unreachable("Error: Don't know how to print token.");
break;
}
diff --git a/src/glsl/glsl_parser_extras.cpp b/src/glsl/glsl_parser_extras.cpp
index 6893c7b..968b33c 100644
--- a/src/glsl/glsl_parser_extras.cpp
+++ b/src/glsl/glsl_parser_extras.cpp
@@ -348,7 +348,7 @@ _mesa_glsl_parse_state::process_version_directive(YYLTYPE *locp, int version,
break;
case API_OPENGLES:
- assert(!"Should not get here.");
+ unreachable("Should not get here.");
/* FALLTHROUGH */
case API_OPENGLES2:
@@ -372,7 +372,7 @@ _mesa_shader_stage_to_string(unsigned stage)
case MESA_SHADER_GEOMETRY: return "geometry";
}
- assert(!"Should not get here.");
+ unreachable("Should not get here.");
return "unknown";
}
diff --git a/src/glsl/glsl_symbol_table.cpp b/src/glsl/glsl_symbol_table.cpp
index 2294dda..fdb9b33 100644
--- a/src/glsl/glsl_symbol_table.cpp
+++ b/src/glsl/glsl_symbol_table.cpp
@@ -43,7 +43,7 @@ public:
dest = &ibo;
break;
default:
- assert(!"Unsupported interface variable mode!");
+ unreachable("Unsupported interface variable mode!");
return false;
}
@@ -65,7 +65,7 @@ public:
case ir_var_shader_out:
return ibo;
default:
- assert(!"Unsupported interface variable mode!");
+ unreachable("Unsupported interface variable mode!");
return NULL;
}
}
diff --git a/src/glsl/glsl_types.cpp b/src/glsl/glsl_types.cpp
index d46d180..7f16fe3 100644
--- a/src/glsl/glsl_types.cpp
+++ b/src/glsl/glsl_types.cpp
@@ -239,7 +239,7 @@ glsl_type::sampler_index() const
case GLSL_SAMPLER_DIM_MS:
return (t->sampler_array) ? TEXTURE_2D_MULTISAMPLE_ARRAY_INDEX : TEXTURE_2D_MULTISAMPLE_INDEX;
default:
- assert(!"Should not get here.");
+ unreachable("Should not get here.");
return TEXTURE_BUFFER_INDEX;
}
}
@@ -471,7 +471,7 @@ glsl_type::get_instance(unsigned base_type, unsigned rows, unsigned columns)
}
}
- assert(!"Should not get here.");
+ unreachable("Should not get here.");
return error_type;
}
@@ -582,7 +582,7 @@ glsl_type::get_sampler_instance(enum glsl_sampler_dim dim,
}
}
- assert(!"Should not get here.");
+ unreachable("Should not get here.");
return error_type;
}
@@ -1011,7 +1011,7 @@ glsl_type::std140_base_alignment(bool row_major) const
return base_alignment;
}
- assert(!"not reached");
+ unreachable("not reached");
return -1;
}
@@ -1138,7 +1138,7 @@ glsl_type::std140_size(bool row_major) const
return size;
}
- assert(!"not reached");
+ unreachable("not reached");
return -1;
}
@@ -1194,7 +1194,7 @@ glsl_type::count_attribute_slots() const
break;
}
- assert(!"Unexpected type in count_attribute_slots()");
+ unreachable("Unexpected type in count_attribute_slots()");
return 0;
}
@@ -1220,7 +1220,7 @@ glsl_type::coordinate_components() const
size = 3;
break;
default:
- assert(!"Should not get here.");
+ unreachable("Should not get here.");
size = 1;
break;
}
diff --git a/src/glsl/ir.cpp b/src/glsl/ir.cpp
index fe5601a..0f83557 100644
--- a/src/glsl/ir.cpp
+++ b/src/glsl/ir.cpp
@@ -61,7 +61,7 @@ update_rhs_swizzle(ir_swizzle_mask &m, unsigned from, unsigned to)
case 1: m.y = from; break;
case 2: m.z = from; break;
case 3: m.w = from; break;
- default: assert(!"Should not get here.");
+ default: unreachable("Should not get here.");
}
m.num_components = MAX2(m.num_components, (to + 1));
@@ -90,7 +90,7 @@ ir_assignment::set_lhs(ir_rvalue *lhs)
case 1: c = swiz->mask.y; break;
case 2: c = swiz->mask.z; break;
case 3: c = swiz->mask.w; break;
- default: assert(!"Should not get here.");
+ default: unreachable("Should not get here.");
}
write_mask |= (((this->write_mask >> i) & 1) << c);
@@ -317,7 +317,7 @@ ir_expression::ir_expression(int op, ir_rvalue *op0)
break;
default:
- assert(!"not reached: missing automatic type setup for ir_expression");
+ unreachable("not reached: missing automatic type setup for ir_expression");
this->type = op0->type;
break;
}
@@ -414,7 +414,7 @@ ir_expression::ir_expression(int op, ir_rvalue *op0, ir_rvalue *op1)
break;
default:
- assert(!"not reached: missing automatic type setup for ir_expression");
+ unreachable("not reached: missing automatic type setup for ir_expression");
this->type = glsl_type::float_type;
}
}
@@ -445,7 +445,7 @@ ir_expression::ir_expression(int op, ir_rvalue *op0, ir_rvalue *op1,
break;
default:
- assert(!"not reached: missing automatic type setup for ir_expression");
+ unreachable("not reached: missing automatic type setup for ir_expression");
this->type = glsl_type::float_type;
}
}
@@ -695,7 +695,7 @@ ir_constant::ir_constant(const ir_constant *c, unsigned i)
case GLSL_TYPE_INT: this->value.i[0] = c->value.i[i]; break;
case GLSL_TYPE_FLOAT: this->value.f[0] = c->value.f[i]; break;
case GLSL_TYPE_BOOL: this->value.b[0] = c->value.b[i]; break;
- default: assert(!"Should not get here."); break;
+ default: unreachable("Should not get here."); break;
}
}
@@ -766,7 +766,7 @@ ir_constant::ir_constant(const struct glsl_type *type, exec_list *value_list)
this->value.b[i] = value->value.b[0];
break;
default:
- assert(!"Should not get here.");
+ unreachable("Should not get here.");
break;
}
}
@@ -869,7 +869,7 @@ ir_constant::get_bool_component(unsigned i) const
case GLSL_TYPE_INT: return this->value.i[i] != 0;
case GLSL_TYPE_FLOAT: return ((int)this->value.f[i]) != 0;
case GLSL_TYPE_BOOL: return this->value.b[i];
- default: assert(!"Should not get here."); break;
+ default: unreachable("Should not get here."); break;
}
/* Must return something to make the compiler happy. This is clearly an
@@ -886,7 +886,7 @@ ir_constant::get_float_component(unsigned i) const
case GLSL_TYPE_INT: return (float) this->value.i[i];
case GLSL_TYPE_FLOAT: return this->value.f[i];
case GLSL_TYPE_BOOL: return this->value.b[i] ? 1.0f : 0.0f;
- default: assert(!"Should not get here."); break;
+ default: unreachable("Should not get here."); break;
}
/* Must return something to make the compiler happy. This is clearly an
@@ -903,7 +903,7 @@ ir_constant::get_int_component(unsigned i) const
case GLSL_TYPE_INT: return this->value.i[i];
case GLSL_TYPE_FLOAT: return (int) this->value.f[i];
case GLSL_TYPE_BOOL: return this->value.b[i] ? 1 : 0;
- default: assert(!"Should not get here."); break;
+ default: unreachable("Should not get here."); break;
}
/* Must return something to make the compiler happy. This is clearly an
@@ -920,7 +920,7 @@ ir_constant::get_uint_component(unsigned i) const
case GLSL_TYPE_INT: return this->value.i[i];
case GLSL_TYPE_FLOAT: return (unsigned) this->value.f[i];
case GLSL_TYPE_BOOL: return this->value.b[i] ? 1 : 0;
- default: assert(!"Should not get here."); break;
+ default: unreachable("Should not get here."); break;
}
/* Must return something to make the compiler happy. This is clearly an
@@ -1026,7 +1026,7 @@ ir_constant::copy_offset(ir_constant *src, int offset)
}
default:
- assert(!"Should not get here.");
+ unreachable("Should not get here.");
break;
}
}
@@ -1058,7 +1058,7 @@ ir_constant::copy_masked_offset(ir_constant *src, int offset, unsigned int mask)
value.b[i+offset] = src->get_bool_component(id++);
break;
default:
- assert(!"Should not get here.");
+ unreachable("Should not get here.");
return;
}
}
@@ -1118,7 +1118,7 @@ ir_constant::has_value(const ir_constant *c) const
return false;
break;
default:
- assert(!"Should not get here.");
+ unreachable("Should not get here.");
return false;
}
}
@@ -1159,7 +1159,7 @@ ir_constant::is_value(float f, int i) const
* Samplers cannot be constants, and the others should have been
* filtered out above.
*/
- assert(!"Should not get here.");
+ unreachable("Should not get here.");
return false;
}
}
@@ -1576,7 +1576,7 @@ interpolation_string(unsigned interpolation)
case INTERP_QUALIFIER_NOPERSPECTIVE: return "noperspective";
}
- assert(!"Should not get here.");
+ unreachable("Should not get here.");
return "";
}
@@ -1611,7 +1611,7 @@ ir_variable::enable_extension_warning(const char *extension)
}
}
- assert(!"Should not get here.");
+ unreachable("Should not get here.");
this->data.warn_extension_index = 0;
}
@@ -1856,7 +1856,7 @@ vertices_per_prim(GLenum prim)
case GL_TRIANGLES_ADJACENCY:
return 6;
default:
- assert(!"Bad primitive");
+ unreachable("Bad primitive");
return 3;
}
}
@@ -1900,6 +1900,6 @@ mode_string(const ir_variable *var)
break;
}
- assert(!"Should not get here.");
+ unreachable("Should not get here.");
return "invalid variable";
}
diff --git a/src/glsl/ir.h b/src/glsl/ir.h
index a0f48b2..169a1c2 100644
--- a/src/glsl/ir.h
+++ b/src/glsl/ir.h
@@ -190,7 +190,7 @@ protected:
private:
ir_instruction()
{
- assert(!"Should not get here.");
+ unreachable("Should not get here.");
}
};
diff --git a/src/glsl/ir_clone.cpp b/src/glsl/ir_clone.cpp
index dffa578..fc46cdd 100644
--- a/src/glsl/ir_clone.cpp
+++ b/src/glsl/ir_clone.cpp
@@ -362,7 +362,7 @@ ir_constant::clone(void *mem_ctx, struct hash_table *ht) const
case GLSL_TYPE_VOID:
case GLSL_TYPE_ERROR:
case GLSL_TYPE_INTERFACE:
- assert(!"Should not get here.");
+ unreachable("Should not get here.");
break;
}
diff --git a/src/glsl/ir_constant_expression.cpp b/src/glsl/ir_constant_expression.cpp
index 1e8b3a3..89f306a 100644
--- a/src/glsl/ir_constant_expression.cpp
+++ b/src/glsl/ir_constant_expression.cpp
@@ -473,7 +473,7 @@ constant_referenced(const ir_dereference *deref,
}
default:
- assert(!"Should not get here.");
+ unreachable("Should not get here.");
break;
}
@@ -1580,7 +1580,7 @@ ir_expression::constant_expression_value(struct hash_table *variable_context)
data.b[idx] = op[1]->value.b[0];
break;
default:
- assert(!"Should not get here.");
+ unreachable("Should not get here.");
break;
}
break;
@@ -1666,7 +1666,7 @@ ir_swizzle::constant_expression_value(struct hash_table *variable_context)
case GLSL_TYPE_INT: data.u[i] = v->value.u[swiz_idx[i]]; break;
case GLSL_TYPE_FLOAT: data.f[i] = v->value.f[swiz_idx[i]]; break;
case GLSL_TYPE_BOOL: data.b[i] = v->value.b[swiz_idx[i]]; break;
- default: assert(!"Should not get here."); break;
+ default: unreachable("Should not get here."); break;
}
}
@@ -1741,7 +1741,7 @@ ir_dereference_array::constant_expression_value(struct hash_table *variable_cont
break;
default:
- assert(!"Should not get here.");
+ unreachable("Should not get here.");
break;
}
diff --git a/src/glsl/ir_equals.cpp b/src/glsl/ir_equals.cpp
index 65376cd..cb51cdf 100644
--- a/src/glsl/ir_equals.cpp
+++ b/src/glsl/ir_equals.cpp
@@ -172,7 +172,7 @@ ir_texture::equals(ir_instruction *ir, enum ir_node_type ignore)
return false;
break;
default:
- assert(!"Unrecognized texture op");
+ unreachable("Unrecognized texture op");
}
return true;
diff --git a/src/glsl/ir_set_program_inouts.cpp b/src/glsl/ir_set_program_inouts.cpp
index 97ead75..43506a8 100644
--- a/src/glsl/ir_set_program_inouts.cpp
+++ b/src/glsl/ir_set_program_inouts.cpp
@@ -189,7 +189,7 @@ ir_set_program_inouts_visitor::try_mark_partial_variable(ir_variable *var,
(type->is_array() &&
(type->fields.array->is_numeric() ||
type->fields.array->is_boolean())))) {
- assert(!"Unexpected indexing in ir_set_program_inouts");
+ unreachable("Unexpected indexing in ir_set_program_inouts");
/* For safety in release builds, in case we ever encounter unexpected
* indexing, give up and let the caller mark the whole variable as used.
diff --git a/src/glsl/ir_validate.cpp b/src/glsl/ir_validate.cpp
index 5a6f8bb..2f0de77 100644
--- a/src/glsl/ir_validate.cpp
+++ b/src/glsl/ir_validate.cpp
@@ -621,7 +621,7 @@ ir_validate::visit_leave(ir_expression *ir)
/* The is_vector assertion above should prevent execution from ever
* getting here.
*/
- assert(!"Should not get here.");
+ unreachable("Should not get here.");
break;
}
}
diff --git a/src/glsl/ir_visitor.h b/src/glsl/ir_visitor.h
index 40f96ff..a1011fa 100644
--- a/src/glsl/ir_visitor.h
+++ b/src/glsl/ir_visitor.h
@@ -45,7 +45,7 @@ public:
* the hierarchy should not have \c visit methods.
*/
/*@{*/
- virtual void visit(class ir_rvalue *) { assert(!"unhandled error_type"); }
+ virtual void visit(class ir_rvalue *) { unreachable("unhandled error_type"); }
virtual void visit(class ir_variable *) = 0;
virtual void visit(class ir_function_signature *) = 0;
virtual void visit(class ir_function *) = 0;
diff --git a/src/glsl/link_interface_blocks.cpp b/src/glsl/link_interface_blocks.cpp
index 0ce502d..99637f4 100644
--- a/src/glsl/link_interface_blocks.cpp
+++ b/src/glsl/link_interface_blocks.cpp
@@ -284,7 +284,7 @@ validate_intrastage_interface_blocks(struct gl_shader_program *prog,
/* Only in, out, and uniform interfaces are legal, so we should
* never get here.
*/
- assert(!"illegal interface type");
+ unreachable("illegal interface type");
continue;
}
diff --git a/src/glsl/link_uniform_block_active_visitor.cpp b/src/glsl/link_uniform_block_active_visitor.cpp
index 9da6a4b..5e25687 100644
--- a/src/glsl/link_uniform_block_active_visitor.cpp
+++ b/src/glsl/link_uniform_block_active_visitor.cpp
@@ -68,7 +68,7 @@ process_block(void *mem_ctx, struct hash_table *ht, ir_variable *var)
return b;
}
- assert(!"Should not get here.");
+ unreachable("Should not get here.");
return NULL;
}
diff --git a/src/glsl/link_uniform_blocks.cpp b/src/glsl/link_uniform_blocks.cpp
index 536fcd4..03e1de4 100644
--- a/src/glsl/link_uniform_blocks.cpp
+++ b/src/glsl/link_uniform_blocks.cpp
@@ -64,7 +64,7 @@ private:
(void) type;
(void) name;
(void) row_major;
- assert(!"Should not get here.");
+ unreachable("Should not get here.");
}
virtual void visit_field(const glsl_type *type, const char *name,
diff --git a/src/glsl/link_uniform_initializers.cpp b/src/glsl/link_uniform_initializers.cpp
index f6a60bc..431ad99 100644
--- a/src/glsl/link_uniform_initializers.cpp
+++ b/src/glsl/link_uniform_initializers.cpp
@@ -88,7 +88,7 @@ copy_constant_to_storage(union gl_constant_value *storage,
/* All other types should have already been filtered by other
* paths in the caller.
*/
- assert(!"Should not get here.");
+ unreachable("Should not get here.");
break;
}
}
@@ -301,7 +301,7 @@ link_set_uniform_initializers(struct gl_shader_program *prog,
} else if (type->contains_atomic()) {
/* we don't actually need to do anything. */
} else {
- assert(!"Explicit binding not on a sampler, UBO or atomic.");
+ unreachable("Explicit binding not on a sampler, UBO or atomic.");
}
} else if (var->constant_value) {
linker::set_uniform_initializer(mem_ctx, prog, var->name,
diff --git a/src/glsl/link_uniforms.cpp b/src/glsl/link_uniforms.cpp
index de2f6c9..6d716d5 100644
--- a/src/glsl/link_uniforms.cpp
+++ b/src/glsl/link_uniforms.cpp
@@ -523,7 +523,7 @@ private:
(void) type;
(void) name;
(void) row_major;
- assert(!"Should not get here.");
+ unreachable("Should not get here.");
}
virtual void visit_field(const glsl_type *type, const char *name,
diff --git a/src/glsl/link_varyings.cpp b/src/glsl/link_varyings.cpp
index 43da2c6..539a1d1 100644
--- a/src/glsl/link_varyings.cpp
+++ b/src/glsl/link_varyings.cpp
@@ -993,7 +993,7 @@ varying_matches::compute_packing_order(const ir_variable *var)
case 3: return PACKING_ORDER_VEC3;
case 0: return PACKING_ORDER_VEC4;
default:
- assert(!"Unexpected value of vector_elements");
+ unreachable("Unexpected value of vector_elements");
return PACKING_ORDER_VEC4;
}
}
@@ -1336,7 +1336,7 @@ assign_varying_locations(struct gl_context *ctx,
consumer_inputs,
consumer_interface_inputs,
consumer_inputs_with_locations)) {
- assert(!"populate_consumer_input_sets failed");
+ unreachable("populate_consumer_input_sets failed");
hash_table_dtor(tfeedback_candidates);
hash_table_dtor(consumer_inputs);
hash_table_dtor(consumer_interface_inputs);
diff --git a/src/glsl/loop_analysis.cpp b/src/glsl/loop_analysis.cpp
index 21d46eb..741e804 100644
--- a/src/glsl/loop_analysis.cpp
+++ b/src/glsl/loop_analysis.cpp
@@ -425,7 +425,7 @@ loop_analysis::visit_leave(ir_loop *ir)
case ir_binop_greater: cmp = ir_binop_less; break;
case ir_binop_lequal: cmp = ir_binop_gequal; break;
case ir_binop_gequal: cmp = ir_binop_lequal; break;
- default: assert(!"Should not get here.");
+ default: unreachable("Should not get here.");
}
}
diff --git a/src/glsl/loop_controls.cpp b/src/glsl/loop_controls.cpp
index 1c1d34f..70f97ba 100644
--- a/src/glsl/loop_controls.cpp
+++ b/src/glsl/loop_controls.cpp
@@ -59,7 +59,7 @@ find_initial_value(ir_loop *loop, ir_variable *var)
case ir_type_function:
case ir_type_function_signature:
- assert(!"Should not get here.");
+ unreachable("Should not get here.");
return NULL;
case ir_type_assignment: {
diff --git a/src/glsl/lower_packed_varyings.cpp b/src/glsl/lower_packed_varyings.cpp
index 5e844c7..85a0c49 100644
--- a/src/glsl/lower_packed_varyings.cpp
+++ b/src/glsl/lower_packed_varyings.cpp
@@ -301,7 +301,7 @@ lower_packed_varyings_visitor::bitwise_assign_pack(ir_rvalue *lhs,
ir_expression(ir_unop_bitcast_f2i, lhs->type, rhs);
break;
default:
- assert(!"Unexpected type conversion while lowering varyings");
+ unreachable("Unexpected type conversion while lowering varyings");
break;
}
}
@@ -335,7 +335,7 @@ lower_packed_varyings_visitor::bitwise_assign_unpack(ir_rvalue *lhs,
ir_expression(ir_unop_bitcast_i2f, lhs->type, rhs);
break;
default:
- assert(!"Unexpected type conversion while lowering varyings");
+ unreachable("Unexpected type conversion while lowering varyings");
break;
}
}
diff --git a/src/glsl/lower_packing_builtins.cpp b/src/glsl/lower_packing_builtins.cpp
index db73c7b..d4da769 100644
--- a/src/glsl/lower_packing_builtins.cpp
+++ b/src/glsl/lower_packing_builtins.cpp
@@ -118,7 +118,7 @@ public:
*rvalue = split_unpack_half_2x16(op0);
break;
case LOWER_PACK_UNPACK_NONE:
- assert(!"not reached");
+ unreachable("not reached");
break;
}
diff --git a/src/glsl/lower_ubo_reference.cpp b/src/glsl/lower_ubo_reference.cpp
index 43dd067..e3f2e96 100644
--- a/src/glsl/lower_ubo_reference.cpp
+++ b/src/glsl/lower_ubo_reference.cpp
@@ -207,12 +207,12 @@ interface_field_name(void *mem_ctx, char *base_name, ir_dereference *d,
}
default:
- assert(!"Should not get here.");
+ unreachable("Should not get here.");
break;
}
}
- assert(!"Should not get here.");
+ unreachable("Should not get here.");
return NULL;
}
@@ -383,7 +383,7 @@ lower_ubo_reference_visitor::handle_rvalue(ir_rvalue **rvalue)
break;
}
default:
- assert(!"not reached");
+ unreachable("not reached");
deref = NULL;
break;
}
diff --git a/src/glsl/lower_variable_index_to_cond_assign.cpp b/src/glsl/lower_variable_index_to_cond_assign.cpp
index d878cb0..e68d139 100644
--- a/src/glsl/lower_variable_index_to_cond_assign.cpp
+++ b/src/glsl/lower_variable_index_to_cond_assign.cpp
@@ -384,7 +384,7 @@ public:
return this->lower_temps;
}
- assert(!"Should not get here.");
+ unreachable("Should not get here.");
return false;
}
diff --git a/src/glsl/lower_vector.cpp b/src/glsl/lower_vector.cpp
index a658410..3a89b80 100644
--- a/src/glsl/lower_vector.cpp
+++ b/src/glsl/lower_vector.cpp
@@ -173,7 +173,7 @@ lower_vector_visitor::handle_rvalue(ir_rvalue **rvalue)
case GLSL_TYPE_INT: d.i[assigned] = c->value.i[0]; break;
case GLSL_TYPE_FLOAT: d.f[assigned] = c->value.f[0]; break;
case GLSL_TYPE_BOOL: d.b[assigned] = c->value.b[0]; break;
- default: assert(!"Should not get here."); break;
+ default: unreachable("Should not get here."); break;
}
write_mask |= (1U << i);
diff --git a/src/glsl/opt_constant_propagation.cpp b/src/glsl/opt_constant_propagation.cpp
index c334e12..7f12a13 100644
--- a/src/glsl/opt_constant_propagation.cpp
+++ b/src/glsl/opt_constant_propagation.cpp
@@ -166,7 +166,7 @@ ir_constant_propagation_visitor::handle_rvalue(ir_rvalue **rvalue)
case 1: channel = swiz->mask.y; break;
case 2: channel = swiz->mask.z; break;
case 3: channel = swiz->mask.w; break;
- default: assert(!"shouldn't be reached"); channel = 0; break;
+ default: unreachable("shouldn't be reached"); channel = 0; break;
}
} else {
channel = i;
@@ -204,7 +204,7 @@ ir_constant_propagation_visitor::handle_rvalue(ir_rvalue **rvalue)
data.b[i] = found->constant->value.b[rhs_channel];
break;
default:
- assert(!"not reached");
+ unreachable("not reached");
break;
}
}
diff --git a/src/glsl/opt_minmax.cpp b/src/glsl/opt_minmax.cpp
index 32fb2d7..4a758a6 100644
--- a/src/glsl/opt_minmax.cpp
+++ b/src/glsl/opt_minmax.cpp
@@ -179,7 +179,7 @@ combine_constant(bool ismin, ir_constant *a, ir_constant *b)
c->value.f[i] = b->value.f[i];
break;
default:
- assert(!"not reached");
+ unreachable("not reached");
}
}
return c;
--
2.1.1
More information about the mesa-dev
mailing list