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

Yaxun Liu via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Aug 7 12:06:58 PDT 2023


yaxunl marked an inline comment as done.
yaxunl 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;
----------------
tra wrote:
> 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;
> ```
> 
will use an integer for that.


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

https://reviews.llvm.org/D154300



More information about the cfe-commits mailing list