From fa67f119f2b3d576a1dbeffdf7e510aea2caf848 Mon Sep 17 00:00:00 2001 From: Jason Ekstrand Date: Tue, 17 May 2022 10:48:40 -0500 Subject: [PATCH] glsl: Drop this != NULL assertions MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit If this == NULL, we'll get a crash which is pretty much the same thing when it comes to ease of debugging. This fixes a giant pile of warnings with GCC 12 of the form: ../src/compiler/glsl/ir.h: In member function ‘ir_dereference* ir_instruction::as_dereference()’: ../src/util/macros.h:149:30: warning: ‘nonnull’ argument ‘this’ compared to NULL [-Wnonnull-compare] 149 | #define assume(expr) ((expr) ? ((void) 0) \ | ~~~~~~~~^~~~~~~~~~~~~~ 150 | : (assert(!"assumption failed"), \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 151 | __builtin_unreachable())) | ~~~~~~~~~~~~~~~~~~~~~~~~~ ../src/compiler/glsl/ir.h:150:7: note: in expansion of macro ‘assume’ 150 | assume(this != NULL); \ | ^~~~~~ ../src/compiler/glsl/ir.h:160:4: note: in expansion of macro ‘AS_BASE’ 160 | AS_BASE(dereference) Reviewed-by: Yonggang Luo Reviewed-by: Emma Anholt Part-of: --- src/compiler/glsl/ir.h | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/compiler/glsl/ir.h b/src/compiler/glsl/ir.h index 3c5f7bc..0b6a773 100644 --- a/src/compiler/glsl/ir.h +++ b/src/compiler/glsl/ir.h @@ -147,12 +147,10 @@ public: #define AS_BASE(TYPE) \ class ir_##TYPE *as_##TYPE() \ { \ - assume(this != NULL); \ return is_##TYPE() ? (ir_##TYPE *) this : NULL; \ } \ const class ir_##TYPE *as_##TYPE() const \ { \ - assume(this != NULL); \ return is_##TYPE() ? (ir_##TYPE *) this : NULL; \ } @@ -164,12 +162,10 @@ public: #define AS_CHILD(TYPE) \ class ir_##TYPE * as_##TYPE() \ { \ - assume(this != NULL); \ return ir_type == ir_type_##TYPE ? (ir_##TYPE *) this : NULL; \ } \ const class ir_##TYPE * as_##TYPE() const \ { \ - assume(this != NULL); \ return ir_type == ir_type_##TYPE ? (const ir_##TYPE *) this : NULL; \ } AS_CHILD(variable) -- 2.7.4