Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[SanitizerCoverage] Add compiler-rt test for -fsanitize-coverage=inli…
…ne-bool-flag Reviewers: kcc, vitalybuka Reviewed By: vitalybuka Subscribers: dberris, #sanitizers, llvm-commits Tags: #sanitizers Differential Revision: https://reviews.llvm.org/D77638
- Loading branch information
1 parent
2a1418f
commit 2d39559
Showing
1 changed file
with
42 additions
and
0 deletions.
There are no files selected for viewing
42 changes: 42 additions & 0 deletions
42
compiler-rt/test/sanitizer_common/TestCases/sanitizer_coverage_inline_bool_flag.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// Tests -fsanitize-coverage=inline-bool-flag,pc-table | ||
// | ||
// REQUIRES: has_sancovcc,stable-runtime | ||
// UNSUPPORTED: i386-darwin | ||
// | ||
// RUN: %clangxx -O0 %s -fsanitize-coverage=inline-bool-flag,pc-table -o %t | ||
// RUN: %run %t 2>&1 | FileCheck %s | ||
// XFAIL: tsan | ||
|
||
#include <assert.h> | ||
#include <stdint.h> | ||
#include <stdio.h> | ||
|
||
const bool *first_flag; | ||
|
||
extern "C" void __sanitizer_cov_bool_flag_init(const bool *start, | ||
const bool *end) { | ||
printf("INIT: %p %p\n", start, end); | ||
assert(end - start > 1); | ||
first_flag = start; | ||
} | ||
|
||
uintptr_t FirstPC; | ||
uintptr_t FirstPCFlag; | ||
|
||
extern "C" void __sanitizer_cov_pcs_init(const uintptr_t *pcs_beg, | ||
const uintptr_t *pcs_end) { | ||
const uintptr_t *B = (const uintptr_t *)pcs_beg; | ||
const uintptr_t *E = (const uintptr_t *)pcs_end; | ||
assert(B + 1 < E); | ||
FirstPC = B[0]; | ||
FirstPCFlag = B[1]; | ||
} | ||
|
||
int main() { | ||
assert(first_flag); | ||
assert(*first_flag); | ||
assert(FirstPC == (uintptr_t)&main); | ||
assert(FirstPCFlag == 1); | ||
fprintf(stderr, "PASS\n"); | ||
// CHECK: PASS | ||
} |