[compiler-rt] 1db5b9c - [sanitizer] Address opendir interceptor test review comments (#222732)

via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 10 12:01:04 PDT 2026


Author: SharonXSharon
Date: 2026-09-10T12:00:59-07:00
New Revision: 1db5b9c26f5c153244e7617ad95ef140a1bdd2a0

URL: https://github.com/llvm/llvm-project/commit/1db5b9c26f5c153244e7617ad95ef140a1bdd2a0
DIFF: https://github.com/llvm/llvm-project/commit/1db5b9c26f5c153244e7617ad95ef140a1bdd2a0.diff

LOG: [sanitizer] Address opendir interceptor test review comments (#222732)

Address comments on https://github.com/llvm/llvm-project/pull/221309 
Move `opendir_null.cpp` to the `Linux` tests, convert the `LD_PRELOAD`
shim from `C++` to `C`, and simplify the null path construction.

Co-authored-by: Sharon Xu <sharonxu at fb.com>

Added: 
    compiler-rt/test/sanitizer_common/TestCases/Linux/opendir_null.cpp

Modified: 
    

Removed: 
    compiler-rt/test/sanitizer_common/TestCases/Posix/opendir_null.cpp


################################################################################
diff  --git a/compiler-rt/test/sanitizer_common/TestCases/Linux/opendir_null.cpp b/compiler-rt/test/sanitizer_common/TestCases/Linux/opendir_null.cpp
new file mode 100644
index 0000000000000..252c454dccab1
--- /dev/null
+++ b/compiler-rt/test/sanitizer_common/TestCases/Linux/opendir_null.cpp
@@ -0,0 +1,20 @@
+// RUN: split-file %s %t
+// RUN: %clang -fno-sanitize=all -fPIC -shared %t/shared.c -o %t/shared.so
+// RUN: %clangxx %t/main.cpp -o %t/main
+// RUN: env LD_PRELOAD=%t/shared.so %run %t/main
+
+//--- shared.c
+#include <dirent.h>
+
+DIR *opendir(const char *path) {
+  (void)path;
+  return 0;
+}
+
+//--- main.cpp
+#include <dirent.h>
+
+int main() {
+  const char *path = nullptr;
+  return opendir(path) != nullptr;
+}

diff  --git a/compiler-rt/test/sanitizer_common/TestCases/Posix/opendir_null.cpp b/compiler-rt/test/sanitizer_common/TestCases/Posix/opendir_null.cpp
deleted file mode 100644
index f35cfda218bea..0000000000000
--- a/compiler-rt/test/sanitizer_common/TestCases/Posix/opendir_null.cpp
+++ /dev/null
@@ -1,19 +0,0 @@
-// REQUIRES: linux
-
-// RUN: split-file %s %t
-// RUN: %clangxx -fno-sanitize=all -fPIC -shared %t/shared.cpp -o %t/shared.so
-// RUN: %clangxx %t/main.cpp -o %t/main
-// RUN: env LD_PRELOAD=%t/shared.so %run %t/main
-
-//--- shared.cpp
-#include <dirent.h>
-
-extern "C" DIR *opendir(const char *) { return nullptr; }
-
-//--- main.cpp
-#include <dirent.h>
-
-int main(int argc, char **argv) {
-  const char *path = argc > 1 ? argv[1] : nullptr;
-  return opendir(path) != nullptr;
-}


        


More information about the llvm-commits mailing list