[PATCH] D154300: [CUDA][HIP] Fix template argument deduction

Artem Belevich via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Jul 11 13:49:30 PDT 2023


tra added inline comments.


================
Comment at: clang/lib/Sema/SemaOverload.cpp:12758-12764
+        std::optional<bool> MorePreferableByCUDA =
+            CheckCUDAPreference(FD, Result);
+        // If FD has different CUDA preference than Result.
+        if (MorePreferableByCUDA) {
+          // FD is less preferable than Result.
+          if (!*MorePreferableByCUDA)
+            continue;
----------------
Maybe `CheckCUDAPreference` should return -1/0/1 or an enum. std::optional does not seem to be very readable here.

E.g. `if(MorePreferableByCUDA)` sounds like it's going to be satisfied when FD is a better choice than Result, but it's not the case.
I think this would be easier to follow:
```
    if (CheckCUDAPreference(FD, Result) <= 0) // or `!= CP_BETTER`
         continue;
```



CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D154300/new/

https://reviews.llvm.org/D154300



More information about the cfe-commits mailing list