summaryrefslogtreecommitdiffstats
path: root/llvm/test/tools/sancov/Inputs/test.cpp
blob: a14b4cb93b00999063506cc67c262b1ebbadf63c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
// compile & generate coverage data using:
// clang++ -g -o test-linux_x86_64 -fsanitize=address -fsanitize-coverage=bb test.cpp ../Inputs/foo.cpp
// ASAN_OPTIONS="coverage=1" ./test-linux_x86_64 && mv test-linux_x86_64.??*.sancov test-linux_x86_64.0.sancov
// ASAN_OPTIONS="coverage=1" ./test-linux_x86_64 1 && mv test-linux_x86_64.??*.sancov test-linux_x86_64.1.sancov

#include <stdio.h>
#include <string>

void foo();

__attribute__((noinline))
std::string bar(std::string str) { printf("bar\n"); return str; }

int main(int argc, char **argv) {
    if (argc == 2)
        foo();
    bar("str");
    printf("main\n");
}
OpenPOWER on IntegriCloud