xref: /llvm-project/clang/test/Driver/coverage.c (revision e1815eb2e1016d74ed8f8e2f459182886cacf733)
1 // RUN: %clang -### -S -fprofile-arcs %s 2>&1 | FileCheck --check-prefix=PROFILE-ARCS %s
2 // RUN: %clang -### -S -fprofile-arcs -fno-profile-arcs %s 2>&1 | FileCheck --check-prefix=NO-PROFILE-ARCS %s
3 
4 // PROFILE-ARCS: "-femit-coverage-data"
5 // PROFILE-ARCS: "-coverage-notes-file" "{{.*}}{{/|\\\\}}coverage.c"
6 // NO-PROFILE-ARCS-NOT: "-femit-coverage-data"
7 
8 // RUN: %clang -### -S -fprofile-arcs %s -o /foo/bar.o 2>&1 | FileCheck --check-prefix=GCNO-LOCATION %s
9 // RUN: %clang_cl -### /c --coverage /Fo/foo/bar.obj -- %s 2>&1 | FileCheck --check-prefix=GCNO-LOCATION %s
10 // RUN: %clang -### -c -fprofile-arcs %s -o foo/bar.o 2>&1 | FileCheck --check-prefix=GCNO-LOCATION-REL %s
11 
12 // GCNO-LOCATION: "-coverage-notes-file" "{{.*}}/foo/bar.gcno"
13 // GCNO-LOCATION-REL: "-coverage-notes-file" "{{.*}}{{/|\\\\}}foo/bar.gcno"
14 
15 /// Test -fprofile-dir=
16 // RUN: not %clang -S -Werror -fprofile-dir=abc %s
17 // RUN: not %clang -S -Werror -ftest-coverage -fprofile-dir=abc %s
18 // RUN: %clang -### -S -fprofile-arcs -fprofile-dir=abc %s 2>&1 | FileCheck --check-prefix=PROFILE-DIR %s
19 // RUN: %clang -### -S --coverage -fprofile-dir=abc %s 2>&1 | FileCheck --check-prefix=PROFILE-DIR %s
20 
21 // PROFILE-DIR: "-coverage-data-file" "abc
22 
23 /// These should only get passed if any of --coverage, -ftest-coverage, or
24 /// -fprofile-arcs is passed.
25 // RUN: %clang -### -c %s 2>&1 | FileCheck --check-prefix=NO-COV %s
26 // NO-COV-NOT: "-coverage-notes-file"
27 // NO-COV-NOT: "-coverage-data-file"
28