[clang] [HLSL] Add "or" intrinsic (PR #128979)

Ashley Coleman via cfe-commits cfe-commits at lists.llvm.org
Thu Feb 27 14:28:15 PST 2025


================
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 -finclude-default-header -triple dxil-pc-shadermodel6.6-library %s -verify -DTEST_FUNC=__builtin_hlsl_or
+// RUN: %clang_cc1 -finclude-default-header -triple dxil-pc-shadermodel6.6-library %s -verify -DTEST_FUNC=__builtin_hlsl_and
+
+
----------------
V-FEXrt wrote:

I'm not sure it is a good idea to DRY the test code here. 

Since test code isn't tested itself it should be immediately obvious what the test code is doing, and while its clever use use `-DTEST_FUNC` in the invocation its an extra level of indirection. Being clever is generally bad for code quality but its extra bad for test code

Less important point: This breaks the convention that you can find an error test at `clang/test/SemaHLSL/BuiltIns/<intrinsic name>-errors.hlsl` which means just for `and`/`or` you have to know to look in a different location which make them harder to find if you've learned the pattern already


The keyword to read about this idea/see other people's thoughts is DAMP
https://stackoverflow.com/questions/6453235/what-does-damp-not-dry-mean-when-talking-about-unit-tests

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


More information about the cfe-commits mailing list