[llvm] [libc] [libc][math] Implement nan(f|l) functions (PR #76690)

via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 3 11:22:39 PST 2024


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {clang-format}-->


:warning: C/C++ code formatter, clang-format found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
git-clang-format --diff 8346e8608f5eb7ad03f2c6beacda43af563b4eae 88fff1b27a407835ff872bcf7f5da7aa4d0d2d4b -- libc/src/math/generic/nan.cpp libc/src/math/generic/nanf.cpp libc/src/math/generic/nanl.cpp libc/src/math/nan.h libc/src/math/nanf.h libc/src/math/nanl.h libc/test/src/math/smoke/nan_test.cpp libc/test/src/math/smoke/nanf_test.cpp libc/test/src/math/smoke/nanl_test.cpp libc/src/__support/str_to_float.h
``````````

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/libc/src/__support/str_to_float.h b/libc/src/__support/str_to_float.h
index 7c27807d26..d154142c46 100644
--- a/libc/src/__support/str_to_float.h
+++ b/libc/src/__support/str_to_float.h
@@ -1056,7 +1056,9 @@ hexadecimal_string_to_float(const char *__restrict src,
 }
 
 template <class T>
-LIBC_INLINE fputil::FPBits<T> nan_from_ncharseq(const char *__restrict ncharseq, ptrdiff_t ncharseq_len, int *error, bool sign = false) {
+LIBC_INLINE fputil::FPBits<T> nan_from_ncharseq(const char *__restrict ncharseq,
+                                                ptrdiff_t ncharseq_len,
+                                                int *error, bool sign = false) {
   using FPBits = typename fputil::FPBits<T>;
   using StorageType = typename FPBits::StorageType;
 
@@ -1081,7 +1083,7 @@ LIBC_INLINE fputil::FPBits<T> nan_from_ncharseq(const char *__restrict ncharseq,
   result = FPBits(result.build_quiet_nan(nan_mantissa));
   if (sign)
     result.set_sign(true);
-  
+
   return result;
 }
 
@@ -1177,7 +1179,9 @@ LIBC_INLINE StrToNumResult<T> strtofloatingpoint(const char *__restrict src) {
           ++index;
         if (src[index] == ')') {
           ++index;
-          result = nan_from_ncharseq<T>(src + (left_paren + 1), index - left_paren - 2, &error, result.get_sign());
+          result = nan_from_ncharseq<T>(src + (left_paren + 1),
+                                        index - left_paren - 2, &error,
+                                        result.get_sign());
           ncharseq_found = true;
         } else {
           index = left_paren;
@@ -1219,8 +1223,7 @@ LIBC_INLINE StrToNumResult<T> strtofloatingpoint(const char *__restrict src) {
   return {T(result), index, error};
 }
 
-template <class T>
-LIBC_INLINE StrToNumResult<T> strtonan(const char *arg) {
+template <class T> LIBC_INLINE StrToNumResult<T> strtonan(const char *arg) {
   using FPBits = typename fputil::FPBits<T>;
 
   FPBits result;

``````````

</details>


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


More information about the llvm-commits mailing list