[compiler-rt] 985580d - [asan][test] Fix `TestCases/alloca_*` ptr-to-long cast on Windows
Alvin Wong via llvm-commits
llvm-commits at lists.llvm.org
Sat Apr 1 10:06:42 PDT 2023
Author: Alvin Wong
Date: 2023-04-02T01:06:15+08:00
New Revision: 985580d7c03c3d0790706089d1f526094dba92ae
URL: https://github.com/llvm/llvm-project/commit/985580d7c03c3d0790706089d1f526094dba92ae
DIFF: https://github.com/llvm/llvm-project/commit/985580d7c03c3d0790706089d1f526094dba92ae.diff
LOG: [asan][test] Fix `TestCases/alloca_*` ptr-to-long cast on Windows
64-bit Windows uses 32-bit long so these casts fail to compile with the
error "cast from pointer to smaller type". Change to instead use
uintptr_t like other tests.
Differential Revision: https://reviews.llvm.org/D147232
Added:
Modified:
compiler-rt/test/asan/TestCases/alloca_big_alignment.cpp
compiler-rt/test/asan/TestCases/alloca_detect_custom_size_.cpp
compiler-rt/test/asan/TestCases/alloca_instruments_all_paddings.cpp
compiler-rt/test/asan/TestCases/alloca_overflow_partial.cpp
compiler-rt/test/asan/TestCases/alloca_overflow_right.cpp
compiler-rt/test/asan/TestCases/alloca_safe_access.cpp
compiler-rt/test/asan/TestCases/alloca_underflow_left.cpp
Removed:
################################################################################
diff --git a/compiler-rt/test/asan/TestCases/alloca_big_alignment.cpp b/compiler-rt/test/asan/TestCases/alloca_big_alignment.cpp
index 0b49424bfae5d..a451e873f2e42 100644
--- a/compiler-rt/test/asan/TestCases/alloca_big_alignment.cpp
+++ b/compiler-rt/test/asan/TestCases/alloca_big_alignment.cpp
@@ -3,10 +3,11 @@
//
#include <assert.h>
+#include <stdint.h>
__attribute__((noinline)) void foo(int index, int len) {
volatile char str[len] __attribute__((aligned(128)));
- assert(!(reinterpret_cast<long>(str) & 127L));
+ assert(!(reinterpret_cast<uintptr_t>(str) & 127L));
str[index] = '1'; // BOOM
// CHECK: ERROR: AddressSanitizer: dynamic-stack-buffer-overflow on address [[ADDR:0x[0-9a-f]+]]
// CHECK: WRITE of size 1 at [[ADDR]] thread T0
diff --git a/compiler-rt/test/asan/TestCases/alloca_detect_custom_size_.cpp b/compiler-rt/test/asan/TestCases/alloca_detect_custom_size_.cpp
index 271359bf70973..8b207aa07f2eb 100644
--- a/compiler-rt/test/asan/TestCases/alloca_detect_custom_size_.cpp
+++ b/compiler-rt/test/asan/TestCases/alloca_detect_custom_size_.cpp
@@ -3,6 +3,7 @@
//
#include <assert.h>
+#include <stdint.h>
struct A {
char a[3];
@@ -11,7 +12,7 @@ struct A {
__attribute__((noinline)) void foo(int index, int len) {
volatile struct A str[len] __attribute__((aligned(32)));
- assert(!(reinterpret_cast<long>(str) & 31L));
+ assert(!(reinterpret_cast<uintptr_t>(str) & 31L));
str[index].a[0] = '1'; // BOOM
// CHECK: ERROR: AddressSanitizer: dynamic-stack-buffer-overflow on address [[ADDR:0x[0-9a-f]+]]
// CHECK: WRITE of size 1 at [[ADDR]] thread T0
diff --git a/compiler-rt/test/asan/TestCases/alloca_instruments_all_paddings.cpp b/compiler-rt/test/asan/TestCases/alloca_instruments_all_paddings.cpp
index 5bf6f80ac4ce7..912c8b0abaabd 100644
--- a/compiler-rt/test/asan/TestCases/alloca_instruments_all_paddings.cpp
+++ b/compiler-rt/test/asan/TestCases/alloca_instruments_all_paddings.cpp
@@ -5,10 +5,11 @@
#include "sanitizer/asan_interface.h"
#include <assert.h>
+#include <stdint.h>
__attribute__((noinline)) void foo(int index, int len) {
volatile char str[len] __attribute__((aligned(32)));
- assert(!(reinterpret_cast<long>(str) & 31L));
+ assert(!(reinterpret_cast<uintptr_t>(str) & 31L));
char *q = (char *)__asan_region_is_poisoned((char *)str, 64);
assert(q && ((q - str) == index));
}
diff --git a/compiler-rt/test/asan/TestCases/alloca_overflow_partial.cpp b/compiler-rt/test/asan/TestCases/alloca_overflow_partial.cpp
index afac40ce6b9a7..25c6d75be7a53 100644
--- a/compiler-rt/test/asan/TestCases/alloca_overflow_partial.cpp
+++ b/compiler-rt/test/asan/TestCases/alloca_overflow_partial.cpp
@@ -3,10 +3,11 @@
//
#include <assert.h>
+#include <stdint.h>
__attribute__((noinline)) void foo(int index, int len) {
volatile char str[len] __attribute__((aligned(32)));
- assert(!(reinterpret_cast<long>(str) & 31L));
+ assert(!(reinterpret_cast<uintptr_t>(str) & 31L));
str[index] = '1'; // BOOM
// CHECK: ERROR: AddressSanitizer: dynamic-stack-buffer-overflow on address [[ADDR:0x[0-9a-f]+]]
// CHECK: WRITE of size 1 at [[ADDR]] thread T0
diff --git a/compiler-rt/test/asan/TestCases/alloca_overflow_right.cpp b/compiler-rt/test/asan/TestCases/alloca_overflow_right.cpp
index 615dd1485be1b..7ec4b86cdc715 100644
--- a/compiler-rt/test/asan/TestCases/alloca_overflow_right.cpp
+++ b/compiler-rt/test/asan/TestCases/alloca_overflow_right.cpp
@@ -3,10 +3,11 @@
//
#include <assert.h>
+#include <stdint.h>
__attribute__((noinline)) void foo(int index, int len) {
volatile char str[len] __attribute__((aligned(32)));
- assert(!(reinterpret_cast<long>(str) & 31L));
+ assert(!(reinterpret_cast<uintptr_t>(str) & 31L));
str[index] = '1'; // BOOM
// CHECK: ERROR: AddressSanitizer: dynamic-stack-buffer-overflow on address [[ADDR:0x[0-9a-f]+]]
// CHECK: WRITE of size 1 at [[ADDR]] thread T0
diff --git a/compiler-rt/test/asan/TestCases/alloca_safe_access.cpp b/compiler-rt/test/asan/TestCases/alloca_safe_access.cpp
index 1cd0dada7b45c..98e31769812bf 100644
--- a/compiler-rt/test/asan/TestCases/alloca_safe_access.cpp
+++ b/compiler-rt/test/asan/TestCases/alloca_safe_access.cpp
@@ -3,10 +3,11 @@
//
#include <assert.h>
+#include <stdint.h>
__attribute__((noinline)) void foo(int index, int len) {
volatile char str[len] __attribute__((aligned(32)));
- assert(!(reinterpret_cast<long>(str) & 31L));
+ assert(!(reinterpret_cast<uintptr_t>(str) & 31L));
str[index] = '1';
}
diff --git a/compiler-rt/test/asan/TestCases/alloca_underflow_left.cpp b/compiler-rt/test/asan/TestCases/alloca_underflow_left.cpp
index 8720e8cce24b3..52cd781c4bb88 100644
--- a/compiler-rt/test/asan/TestCases/alloca_underflow_left.cpp
+++ b/compiler-rt/test/asan/TestCases/alloca_underflow_left.cpp
@@ -3,10 +3,11 @@
//
#include <assert.h>
+#include <stdint.h>
__attribute__((noinline)) void foo(int index, int len) {
volatile char str[len] __attribute__((aligned(32)));
- assert(!(reinterpret_cast<long>(str) & 31L));
+ assert(!(reinterpret_cast<uintptr_t>(str) & 31L));
str[index] = '1'; // BOOM
// CHECK: ERROR: AddressSanitizer: dynamic-stack-buffer-overflow on address [[ADDR:0x[0-9a-f]+]]
// CHECK: WRITE of size 1 at [[ADDR]] thread T0
More information about the llvm-commits
mailing list