[compiler-rt] [compiler-rt][nsan] Fix strsep interceptor (PR #106307)

via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 27 16:25:12 PDT 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 1022323c9b7cd4b9506e25f8f353da632761801e 311ee4196fef59be6aeed8716648af1971308c97 --extensions cpp -- compiler-rt/test/nsan/intercep_strsep.cpp compiler-rt/lib/nsan/nsan_interceptors.cpp
``````````

</details>

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

``````````diff
diff --git a/compiler-rt/test/nsan/intercep_strsep.cpp b/compiler-rt/test/nsan/intercep_strsep.cpp
index 69accd53c4..4ae676fe20 100644
--- a/compiler-rt/test/nsan/intercep_strsep.cpp
+++ b/compiler-rt/test/nsan/intercep_strsep.cpp
@@ -1,25 +1,24 @@
 // RUN: %clangxx_nsan -O2 %s -o %t
 // RUN: %run %t 2>&1 | FileCheck %s
 
-#include <iostream>
 #include <cstring>
+#include <iostream>
 
 extern "C" void __nsan_dump_shadow_mem(const char *addr, size_t size_bytes,
                                        size_t bytes_per_line, size_t reserved);
 
 int main() {
-    // Define a C-style string with commas as delimiters
-    char input[] = "apple,banana,cherry,date";
-    char* token;
-    char* rest = input; // Pointer to keep track of the rest of the string
+  // Define a C-style string with commas as delimiters
+  char input[] = "apple,banana,cherry,date";
+  char *token;
+  char *rest = input; // Pointer to keep track of the rest of the string
 
-    // Tokenize the string using strsep
-    while ((token = strsep(&rest, ",")) != NULL) {
-        std::cout << token << std::endl;
-    }
+  // Tokenize the string using strsep
+  while ((token = strsep(&rest, ",")) != NULL) {
+    std::cout << token << std::endl;
+  }
 
-    __nsan_dump_shadow_mem(&input[5], 1, 1, 0);
-    // CHECK: 0x{{[a-f0-9]*}}:    _
-    return 0;
+  __nsan_dump_shadow_mem(&input[5], 1, 1, 0);
+  // CHECK: 0x{{[a-f0-9]*}}:    _
+  return 0;
 }
-

``````````

</details>


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


More information about the llvm-commits mailing list