Make test more lenient for custom clang version strings
[llvm-project.git] / compiler-rt / test / asan / TestCases / invalid-pointer-pairs-compare-success.cpp
blobd0d92265f0023344ded77fb2b55cfca4787bf23e
1 // RUN: %clangxx_asan -O0 %s -o %t -mllvm -asan-detect-invalid-pointer-pair
3 // RUN: %env_asan_opts=detect_invalid_pointer_pairs=2 %run %t
5 #include <assert.h>
6 #include <stdlib.h>
8 int foo(char *p) {
9 char *p2 = p + 20;
10 return p > p2;
13 int bar(char *p, char *q) {
14 return p <= q;
17 int baz(char *p, char *q) {
18 return p != 0 && p < q;
21 char global[8192] = {};
22 char small_global[7] = {};
24 int main() {
25 // Heap allocated memory.
26 char *p = (char *)malloc(42);
27 int r = foo(p);
28 free(p);
30 p = (char *)malloc(1024);
31 bar(p, p + 1024);
32 bar(p + 1024, p + 1023);
33 bar(p + 1, p + 1023);
34 free(p);
36 p = (char *)malloc(4096);
37 bar(p, p + 4096);
38 bar(p + 10, p + 100);
39 bar(p + 1024, p + 4096);
40 bar(p + 4095, p + 4096);
41 bar(p + 4095, p + 4094);
42 bar(p + 100, p + 4096);
43 bar(p + 100, p + 4094);
44 free(p);
46 // Global variable.
47 bar(&global[0], &global[1]);
48 bar(&global[1], &global[2]);
49 bar(&global[2], &global[1]);
50 bar(&global[0], &global[100]);
51 bar(&global[1000], &global[7000]);
52 bar(&global[500], &global[10]);
53 p = &global[0];
54 bar(p, p + 8192);
55 p = &global[8000];
56 bar(p, p + 192);
58 p = &small_global[0];
59 bar(p, p + 1);
60 bar(p, p + 7);
61 bar(p + 7, p + 1);
62 bar(p + 6, p + 7);
63 bar(p + 7, p + 7);
65 // Stack variable.
66 char stack[10000];
67 bar(&stack[0], &stack[100]);
68 bar(&stack[1000], &stack[9000]);
69 bar(&stack[500], &stack[10]);
71 baz(0, &stack[10]);
73 return 0;