[clang] [HLSL] Add `InterlockedExchange` function and resource methods (PR #222161)

Helena Kotas via cfe-commits cfe-commits at lists.llvm.org
Mon Sep 21 20:54:28 PDT 2026


================
@@ -898,15 +899,21 @@ static void defineHLSLInterlockedFunc(Sema &S, NamespaceDecl *NS,
 
   for (QualType ElemTy : Elems)
     for (LangAS AS : AddrSpaces)
-      for (bool ThreeArg : {false, true})
+      for (bool ThreeArg : {false, true}) {
+        if (RequiresOriginalValue && !ThreeArg)
+          continue;
         buildAtomicOverload(S, NS, FuncName, BuiltinName, ElemTy, AS, ThreeArg);
+      }
----------------
hekota wrote:

```suggestion
      if (!RequiresOriginalValue)
        buildAtomicOverload(S, NS, FuncName, BuiltinName, ElemTy, AS, /*ThreeArg*/ false);
      buildAtomicOverload(S, NS, FuncName, BuiltinName, ElemTy, AS, /*ThreeArg*/ true);
```
Suggestion. Looping over {false, true} and then conditionally skipping over one iteration feels a little clumsy.

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


More information about the cfe-commits mailing list