[compiler-rt] b9af157 - [ASan/Win] Hide index from compiler to avoid new clang warning

Reid Kleckner via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 11 16:12:36 PDT 2021


Author: Reid Kleckner
Date: 2021-06-11T16:12:28-07:00
New Revision: b9af157fd18d375ac689ae241b831ccd95c42243

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

LOG: [ASan/Win] Hide index from compiler to avoid new clang warning

Added: 
    

Modified: 
    compiler-rt/test/asan/TestCases/Windows/dll_operator_array_new_with_dtor_left_oob.cpp
    compiler-rt/test/asan/TestCases/Windows/operator_array_new_with_dtor_left_oob.cpp

Removed: 
    


################################################################################
diff  --git a/compiler-rt/test/asan/TestCases/Windows/dll_operator_array_new_with_dtor_left_oob.cpp b/compiler-rt/test/asan/TestCases/Windows/dll_operator_array_new_with_dtor_left_oob.cpp
index a08524f7b5b9..e81057d889d9 100644
--- a/compiler-rt/test/asan/TestCases/Windows/dll_operator_array_new_with_dtor_left_oob.cpp
+++ b/compiler-rt/test/asan/TestCases/Windows/dll_operator_array_new_with_dtor_left_oob.cpp
@@ -7,10 +7,12 @@ struct C {
   ~C() {}
 };
 
+int __attribute__((noinline, optnone)) hide(int x) { return x; }
+
 extern "C" __declspec(dllexport)
 int test_function() {
   C *buffer = new C[42];
-  buffer[-(1 + sizeof(void*) / 4)].x = 42;
+  buffer[hide(-(1 + (int)sizeof(void*) / 4))].x = 42;
 // CHECK: AddressSanitizer: heap-buffer-overflow on address [[ADDR:0x[0-9a-f]+]]
 // CHECK: WRITE of size 4 at [[ADDR]] thread T0
 // CHECK-NEXT: test_function {{.*}}dll_operator_array_new_with_dtor_left_oob.cpp:[[@LINE-3]]

diff  --git a/compiler-rt/test/asan/TestCases/Windows/operator_array_new_with_dtor_left_oob.cpp b/compiler-rt/test/asan/TestCases/Windows/operator_array_new_with_dtor_left_oob.cpp
index 0af00fb7c6df..97e85f4f9612 100644
--- a/compiler-rt/test/asan/TestCases/Windows/operator_array_new_with_dtor_left_oob.cpp
+++ b/compiler-rt/test/asan/TestCases/Windows/operator_array_new_with_dtor_left_oob.cpp
@@ -6,9 +6,11 @@ struct C {
   ~C() {}
 };
 
+int __attribute__((noinline, optnone)) hide(int x) { return x; }
+
 int main() {
   C *buffer = new C[42];
-  buffer[-(1 + sizeof(void*) / 4)].x = 42;
+  buffer[hide(-(1 + (int)sizeof(void*) / 4))].x = 42;
 // CHECK: AddressSanitizer: heap-buffer-overflow on address [[ADDR:0x[0-9a-f]+]]
 // CHECK: WRITE of size 4 at [[ADDR]] thread T0
 // CHECK-NEXT: {{#0 .* main .*operator_array_new_with_dtor_left_oob.cpp}}:[[@LINE-3]]


        


More information about the llvm-commits mailing list