[tint][ir][Builder] Prevent coercion to Constant(bool)
This is almost never what you want. Make this overload explicit.
Change-Id: I9d1994ffc5c82b90aaf551dfee025b5cb77a01a4
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/140741
Reviewed-by: James Price <jrprice@google.com>
Auto-Submit: Ben Clayton <bclayton@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
diff --git a/src/tint/ir/builder.h b/src/tint/ir/builder.h
index ffd3a20..65f7df9 100644
--- a/src/tint/ir/builder.h
+++ b/src/tint/ir/builder.h
@@ -218,7 +218,10 @@
/// Creates a ir::Constant for a bool Scalar
/// @param v the value
/// @returns the new constant
- ir::Constant* Constant(bool v) { return Constant(ir.constant_values.Get(v)); }
+ template <typename BOOL, typename = std::enable_if_t<std::is_same_v<BOOL, bool>>>
+ ir::Constant* Constant(BOOL v) {
+ return Constant(ir.constant_values.Get(v));
+ }
/// @param in the input value. One of: nullptr, ir::Value*, ir::Instruction* or a numeric value.
/// @returns an ir::Value* from the given argument.