Skip to content

Commit 2d39559

Browse files
pratyaivitalybuka
authored andcommitted
[SanitizerCoverage] Add compiler-rt test for -fsanitize-coverage=inline-bool-flag
Reviewers: kcc, vitalybuka Reviewed By: vitalybuka Subscribers: dberris, #sanitizers, llvm-commits Tags: #sanitizers Differential Revision: https://reviews.llvm.org/D77638
1 parent 2a1418f commit 2d39559

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
// Tests -fsanitize-coverage=inline-bool-flag,pc-table
2+
//
3+
// REQUIRES: has_sancovcc,stable-runtime
4+
// UNSUPPORTED: i386-darwin
5+
//
6+
// RUN: %clangxx -O0 %s -fsanitize-coverage=inline-bool-flag,pc-table -o %t
7+
// RUN: %run %t 2>&1 | FileCheck %s
8+
// XFAIL: tsan
9+
10+
#include <assert.h>
11+
#include <stdint.h>
12+
#include <stdio.h>
13+
14+
const bool *first_flag;
15+
16+
extern "C" void __sanitizer_cov_bool_flag_init(const bool *start,
17+
const bool *end) {
18+
printf("INIT: %p %p\n", start, end);
19+
assert(end - start > 1);
20+
first_flag = start;
21+
}
22+
23+
uintptr_t FirstPC;
24+
uintptr_t FirstPCFlag;
25+
26+
extern "C" void __sanitizer_cov_pcs_init(const uintptr_t *pcs_beg,
27+
const uintptr_t *pcs_end) {
28+
const uintptr_t *B = (const uintptr_t *)pcs_beg;
29+
const uintptr_t *E = (const uintptr_t *)pcs_end;
30+
assert(B + 1 < E);
31+
FirstPC = B[0];
32+
FirstPCFlag = B[1];
33+
}
34+
35+
int main() {
36+
assert(first_flag);
37+
assert(*first_flag);
38+
assert(FirstPC == (uintptr_t)&main);
39+
assert(FirstPCFlag == 1);
40+
fprintf(stderr, "PASS\n");
41+
// CHECK: PASS
42+
}

0 commit comments

Comments
 (0)