[libc-commits] [libc] [libc] Implement tmpfile and corresponding tests (PR #213396)
via libc-commits
libc-commits at lists.llvm.org
Mon Aug 3 10:48:21 PDT 2026
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 origin/main HEAD --extensions cpp,h -- libc/src/stdio/linux/tmpfile.cpp libc/src/stdio/tmpfile.h libc/test/src/stdio/tmpfile_test.cpp --diff_from_common_commit
``````````
:warning:
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing `origin/main` to the base branch/commit you want to compare against.
:warning:
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/libc/src/stdio/linux/tmpfile.cpp b/libc/src/stdio/linux/tmpfile.cpp
index 9741877df..ca915df10 100644
--- a/libc/src/stdio/linux/tmpfile.cpp
+++ b/libc/src/stdio/linux/tmpfile.cpp
@@ -1,4 +1,5 @@
-//===-- Implementation of tmpfile --------------------------------*- C++ -*-===//
+//===-- Implementation of tmpfile --------------------------------*- C++
+//-*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -8,8 +9,8 @@
#include "src/stdio/tmpfile.h"
#include "hdr/fcntl_macros.h"
-#include "src/__support/OSUtil/linux/syscall_wrappers/open.h"
#include "hdr/types/FILE.h"
+#include "src/__support/OSUtil/linux/syscall_wrappers/open.h"
#include "src/__support/File/linux/file.h"
#include "src/__support/common.h"
diff --git a/libc/src/stdio/tmpfile.h b/libc/src/stdio/tmpfile.h
index 680663a77..99ae7abd2 100644
--- a/libc/src/stdio/tmpfile.h
+++ b/libc/src/stdio/tmpfile.h
@@ -1,4 +1,5 @@
-//===-- Implementation header of tmpfile ---------------------------*- C++ -*-===//
+//===-- Implementation header of tmpfile ---------------------------*- C++
+//-*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/libc/test/src/stdio/tmpfile_test.cpp b/libc/test/src/stdio/tmpfile_test.cpp
index c6e7e4229..4c8f64e6d 100644
--- a/libc/test/src/stdio/tmpfile_test.cpp
+++ b/libc/test/src/stdio/tmpfile_test.cpp
@@ -7,13 +7,13 @@
//===----------------------------------------------------------------------===//
//
#include "hdr/stdio_macros.h"
-#include "src/stdio/tmpfile.h"
#include "src/stdio/fclose.h"
#include "src/stdio/fflush.h"
#include "src/stdio/fread.h"
#include "src/stdio/fseek.h"
#include "src/stdio/ftell.h"
#include "src/stdio/fwrite.h"
+#include "src/stdio/tmpfile.h"
#include "test/UnitTest/Test.h"
constexpr char TEST_STR[] = "test\xaa\t\xbb";
@@ -25,7 +25,8 @@ TEST(LlvmLibcTmpfileTest, CreationAndInvariants) {
EXPECT_EQ(LIBC_NAMESPACE::ftell(file), 0L);
- size_t nbytes_written = LIBC_NAMESPACE::fwrite(TEST_STR, 1, TEST_STR_SIZE, file);
+ size_t nbytes_written =
+ LIBC_NAMESPACE::fwrite(TEST_STR, 1, TEST_STR_SIZE, file);
EXPECT_EQ(nbytes_written, TEST_STR_SIZE);
EXPECT_EQ(LIBC_NAMESPACE::fflush(file), 0);
@@ -34,10 +35,7 @@ TEST(LlvmLibcTmpfileTest, CreationAndInvariants) {
EXPECT_EQ(LIBC_NAMESPACE::fseek(file, 0, SEEK_SET), 0);
EXPECT_EQ(LIBC_NAMESPACE::ftell(file), 0L);
-
char buff[TEST_STR_SIZE * 2];
size_t nbytes_read = LIBC_NAMESPACE::fread(buff, 1, TEST_STR_SIZE, file);
EXPECT_EQ(nbytes_read, TEST_STR_SIZE);
-
}
-
``````````
</details>
https://github.com/llvm/llvm-project/pull/213396
More information about the libc-commits
mailing list