Skip to content

[libc][bazel] Add targets for strfrom<float> #128956

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 26, 2025

Conversation

michaelrj-google
Copy link
Contributor

Add targets and tests for strfromf, strfromd and strfroml.

No idea why the standard committee decided that the long double function
should be "strfroml" instead of "strfromld" which would match "strtold"
and leave them space to add string from integer functions in future.

Add targets and tests for strfromf, strfromd and strfroml.

No idea why the standard committee decided that the long double function
should be "strfroml" instead of "strfromld" which would match "strtold"
and leave them space to add string from integer functions in future.
@llvmbot llvmbot added libc bazel "Peripheral" support tier build system: utils/bazel labels Feb 26, 2025
@llvmbot
Copy link
Member

llvmbot commented Feb 26, 2025

@llvm/pr-subscribers-libc

Author: Michael Jones (michaelrj-google)

Changes

Add targets and tests for strfromf, strfromd and strfroml.

No idea why the standard committee decided that the long double function
should be "strfroml" instead of "strfromld" which would match "strtold"
and leave them space to add string from integer functions in future.


Full diff: https://github.com/llvm/llvm-project/pull/128956.diff

2 Files Affected:

  • (modified) utils/bazel/llvm-project-overlay/libc/BUILD.bazel (+43)
  • (modified) utils/bazel/llvm-project-overlay/libc/test/src/stdlib/BUILD.bazel (+31)
diff --git a/utils/bazel/llvm-project-overlay/libc/BUILD.bazel b/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
index c7654ed0b8797..b45145acc2cfe 100644
--- a/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
+++ b/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
@@ -3571,6 +3571,49 @@ libc_function(
     ],
 )
 
+libc_support_library(
+    name = "str_from_util",
+    hdrs = ["src/stdlib/str_from_util.h"],
+    deps = [
+        ":__support_common",
+        ":__support_cpp_type_traits",
+        ":__support_str_to_integer",
+        ":printf_converter",
+        ":printf_core_structs",
+        ":printf_writer",
+    ],
+)
+
+libc_function(
+    name = "strfromf",
+    srcs = ["src/stdlib/strfromf.cpp"],
+    hdrs = ["src/stdlib/strfromf.h"],
+    deps = [
+        ":__support_common",
+        ":str_from_util",
+    ],
+)
+
+libc_function(
+    name = "strfromd",
+    srcs = ["src/stdlib/strfromd.cpp"],
+    hdrs = ["src/stdlib/strfromd.h"],
+    deps = [
+        ":__support_common",
+        ":str_from_util",
+    ],
+)
+
+libc_function(
+    name = "strfroml",
+    srcs = ["src/stdlib/strfroml.cpp"],
+    hdrs = ["src/stdlib/strfroml.h"],
+    deps = [
+        ":__support_common",
+        ":str_from_util",
+    ],
+)
+
 libc_function(
     name = "strtol",
     srcs = ["src/stdlib/strtol.cpp"],
diff --git a/utils/bazel/llvm-project-overlay/libc/test/src/stdlib/BUILD.bazel b/utils/bazel/llvm-project-overlay/libc/test/src/stdlib/BUILD.bazel
index a8b37c5ddcc2c..2566607fc053b 100644
--- a/utils/bazel/llvm-project-overlay/libc/test/src/stdlib/BUILD.bazel
+++ b/utils/bazel/llvm-project-overlay/libc/test/src/stdlib/BUILD.bazel
@@ -149,6 +149,37 @@ libc_test(
     deps = ["//libc:types_size_t"],
 )
 
+libc_support_library(
+    name = "strfrom_test_support",
+    hdrs = ["StrfromTest.h"],
+    deps = [
+        "//libc:__support_cpp_type_traits",
+        "//libc:__support_fputil_fp_bits",
+        "//libc/test/UnitTest:LibcUnitTest",
+    ],
+)
+
+libc_test(
+    name = "strfromf_test",
+    srcs = ["strfromf_test.cpp"],
+    libc_function_deps = ["//libc:strfromf"],
+    deps = [":strfrom_test_support"],
+)
+
+libc_test(
+    name = "strfromd_test",
+    srcs = ["strfromd_test.cpp"],
+    libc_function_deps = ["//libc:strfromd"],
+    deps = [":strfrom_test_support"],
+)
+
+libc_test(
+    name = "strfroml_test",
+    srcs = ["strfroml_test.cpp"],
+    libc_function_deps = ["//libc:strfroml"],
+    deps = [":strfrom_test_support"],
+)
+
 libc_support_library(
     name = "strtol_test_helper",
     hdrs = ["StrtolTest.h"],

@michaelrj-google michaelrj-google merged commit 524711c into llvm:main Feb 26, 2025
9 checks passed
@michaelrj-google michaelrj-google deleted the libcStrFromBazel branch February 26, 2025 23:30
joaosaffran pushed a commit to joaosaffran/llvm-project that referenced this pull request Mar 3, 2025
Add targets and tests for strfromf, strfromd and strfroml.

No idea why the standard committee decided that the long double function
should be "strfroml" instead of "strfromld" which would match "strtold"
and leave them space to add string from integer functions in future.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bazel "Peripheral" support tier build system: utils/bazel libc
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants