[PATCH] D119495: [sanitizer] Check if directory exists before trying to create

Vitaly Buka via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 10 19:33:59 PST 2022


vitalybuka accepted this revision.
vitalybuka added a comment.
This revision is now accepted and ready to land.

it would be nice to have unittests:
TEST(SanitizerCommon, FileExists)
TEST(SanitizerCommon, DirExists)
TEST(SanitizerCommon, RecursiveCreateParentDirs)



================
Comment at: compiler-rt/lib/sanitizer_common/sanitizer_file.cpp:86-93
+    if (!DirExists(path)) {
+      if (!CreateDir(path)) {
+        const char *ErrorMsgPrefix = "ERROR: Can't create directory: ";
+        WriteToFile(kStderrFd, ErrorMsgPrefix, internal_strlen(ErrorMsgPrefix));
+        WriteToFile(kStderrFd, path, internal_strlen(path));
+        Die();
+      }
----------------



================
Comment at: compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp:513
+
 #if !SANITIZER_NETBSD
 tid_t GetTid() {
----------------
please clang-format


================
Comment at: compiler-rt/lib/sanitizer_common/sanitizer_win.cpp:93
 bool FileExists(const char *filename) {
   return ::GetFileAttributesA(filename) != INVALID_FILE_ATTRIBUTES;
 }
----------------
hm looks like existing code is wrong


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D119495/new/

https://reviews.llvm.org/D119495



More information about the llvm-commits mailing list