Files
clang-p2996/compiler-rt/test/asan/TestCases/memcmp_test.cpp
Hau Hsu 404bc5ca2a [Asan] Loose call stack CHECK conditions
These test cases are checking specific functions in call stacks.
But if the call stack order is changed (e.g. another function is not inlined),
the frame number would be different.
This patch loose the frame number checks for those conditions.

Depends on D139827

Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D152991
2023-07-27 18:00:21 -07:00

18 lines
652 B
C++

// RUN: %clangxx_asan -O0 %s -o %t && not %run %t 2>&1 | FileCheck %s
// RUN: %clangxx_asan -O1 %s -o %t && not %run %t 2>&1 | FileCheck %s
// RUN: %clangxx_asan -O2 %s -o %t && not %run %t 2>&1 | FileCheck %s
// RUN: %clangxx_asan -O3 %s -o %t && not %run %t 2>&1 | FileCheck %s
// REQUIRES: compiler-rt-optimized
#include <string.h>
int main(int argc, char **argv) {
char a1[] = {static_cast<char>(argc), 2, 3, 4};
char a2[] = {1, static_cast<char>(2*argc), 3, 4};
int res = memcmp(a1, a2, 4 + argc); // BOOM
// CHECK: AddressSanitizer: stack-buffer-overflow
// CHECK: {{#[0-9]+ .*memcmp}}
// CHECK: {{#[0-9]+ .*main}}
return res;
}