[PATCH] D132739: [clang][Interp] Implement IntegralToBoolean casts

Shafik Yaghmour via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Aug 26 17:16:27 PDT 2022


shafik added inline comments.


================
Comment at: clang/lib/AST/Interp/Boolean.h:90
+  template <typename T> static Boolean from(T Value) {
+    if constexpr (std::is_integral<T>::value)
+      return Boolean(Value != 0);
----------------
This should work for `floating_point` as well.


================
Comment at: clang/lib/AST/Interp/Boolean.h:91
+    if constexpr (std::is_integral<T>::value)
+      return Boolean(Value != 0);
+    return Boolean(static_cast<decltype(Boolean::V)>(Value) != 0);
----------------
Why the `!= 0` shouldn't these all implicitly convert to `bool` with appropriate values?


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

https://reviews.llvm.org/D132739



More information about the cfe-commits mailing list