[compiler-rt] [Sanitizer] Option to fallback to stderr if unable to open logfile (PR #158687)

via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 15 10:05:29 PDT 2025


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 inc,cpp,h -- compiler-rt/lib/sanitizer_common/sanitizer_file.cpp compiler-rt/lib/sanitizer_common/sanitizer_file.h compiler-rt/lib/sanitizer_common/sanitizer_flags.inc compiler-rt/test/sanitizer_common/TestCases/Posix/sanitizer_set_report_path_fail.cpp
``````````

: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/compiler-rt/lib/sanitizer_common/sanitizer_file.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_file.cpp
index 4e691d076..c4a6f8405 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_file.cpp
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_file.cpp
@@ -79,7 +79,7 @@ void ReportFile::ReopenIfNecessary() {
     WriteToFile(kStderrFd, errmsg, internal_strlen(errmsg));
     if (!common_flags()->log_fallback_to_stderr)
       Die();
-    const char *errmsg2 = "ERROR: Fallback to stderr\n";
+    const char* errmsg2 = "ERROR: Fallback to stderr\n";
     WriteToFile(kStderrFd, errmsg2, internal_strlen(errmsg2));
     lastOpenFailed = true;
     fd = kStderrFd;
@@ -87,7 +87,7 @@ void ReportFile::ReopenIfNecessary() {
   fd_pid = pid;
 }
 
-static void RecursiveCreateParentDirs(char *path, fd_t &fd) {
+static void RecursiveCreateParentDirs(char* path, fd_t& fd) {
   if (path[0] == '\0')
     return;
   for (int i = 1; path[i] != '\0'; ++i) {
@@ -104,7 +104,7 @@ static void RecursiveCreateParentDirs(char *path, fd_t &fd) {
       if (!common_flags()->log_fallback_to_stderr)
         Die();
       path[i] = save;
-      const char *ErrorMsgSuffix2 = "ERROR: Fallback to stderr\n";
+      const char* ErrorMsgSuffix2 = "ERROR: Fallback to stderr\n";
       WriteToFile(kStderrFd, ErrorMsgSuffix2, internal_strlen(ErrorMsgSuffix2));
       fd = kStderrFd;
       return;
@@ -185,7 +185,7 @@ void ReportFile::SetReportPath(const char *path) {
       WriteToFile(kStderrFd, message, internal_strlen(message));
       if (!common_flags()->log_fallback_to_stderr)
         Die();
-      const char *message2 = "ERROR: Fallback to stderr\n";
+      const char* message2 = "ERROR: Fallback to stderr\n";
       WriteToFile(kStderrFd, message2, internal_strlen(message2));
       path = "stderr";
     }

``````````

</details>


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


More information about the llvm-commits mailing list