[clang] [HLSL] Add bounds checks for the hlsl vector arguments and return types (PR #130724)

Farzon Lotfi via cfe-commits cfe-commits at lists.llvm.org
Tue Mar 11 09:38:48 PDT 2025


================
@@ -89,23 +89,31 @@ void asuint(double4, out uint4, out uint4);
 /// \param X The X input value.
 /// \param Y The Y input value.
 
+template <typename T>
 _HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
-const inline half distance(half X, half Y) {
+const inline __detail::enable_if_t<__detail::is_arithmetic<T>::Value &&
+                                       __detail::is_same<half, T>::value,
----------------
farzonl wrote:

I didn't add `is_same` thats been in `clang/lib/Headers/hlsl/hlsl_detail.h` for a long time. predating most the other stuff like `enable_if_t` and `is_arithmetic`.

https://github.com/llvm/llvm-project/pull/130724


More information about the cfe-commits mailing list