Skip to content

Commit 379b7b4

Browse files
benlangmuirakyrtzi
authored andcommitted
[clang][cas] Strip -coverage-data-file and -coverage-notes-file from PCH
Companion to https://reviews.llvm.org/D147282; when caching a PCH, remove the -coverage-data-file and -coverage-notes-file options. These paths cannot currently be prefix-mapped, because they are emitted into the binary for the coverage runtime to use. However, they have no effect on PCH, so remove them. rdar://107443796 (cherry picked from commit 0d086a5) (cherry picked from commit eb9236e)
1 parent 20d4eb7 commit 379b7b4

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed

clang/lib/Tooling/DependencyScanning/ScanAndUpdateArgs.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,12 @@ void tooling::dependencies::configureInvocationForCaching(
2929
// Clear this otherwise it defeats the purpose of making the compilation key
3030
// independent of certain arguments.
3131
CI.getCodeGenOpts().DwarfDebugFlags.clear();
32+
if (FrontendOpts.ProgramAction == frontend::GeneratePCH) {
33+
// Clear paths that are emitted into binaries; they do not affect PCH.
34+
// For modules this is handled in ModuleDepCollector.
35+
CI.getCodeGenOpts().CoverageDataFile.clear();
36+
CI.getCodeGenOpts().CoverageNotesFile.clear();
37+
}
3238

3339
// "Fix" the CAS options.
3440
auto &FileSystemOpts = CI.getFileSystemOpts();

clang/test/CAS/depscan-include-tree.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
// RUN: split-file %s %t
33

44
// RUN: %clang -cc1depscan -o %t/inline.rsp -fdepscan=inline -fdepscan-include-tree -cc1-args -cc1 -triple x86_64-apple-macos11.0 \
5-
// RUN: -emit-obj %t/t.c -o %t/t.o -dwarf-ext-refs -fmodule-format=obj \
5+
// RUN: -emit-obj %t/t.c -o %t/t.o -dwarf-ext-refs -fmodule-format=obj \
6+
// RUN: -ftest-coverage -coverage-notes-file %t/t.gcno -coverage-data-file %t/t.gcda \
67
// RUN: -I %t/includes -isysroot %S/Inputs/SDK -fcas-path %t/cas -DSOME_MACRO -dependency-file %t/inline.d -MT deps
78

89
// RUN: FileCheck %s -input-file %t/inline.rsp -DPREFIX=%t
@@ -13,6 +14,9 @@
1314
// CHECK: "-fcas-path" "[[PREFIX]]/cas"
1415
// CHECK: "-fcas-include-tree"
1516
// CHECK: "-isysroot"
17+
// CHECK: "-ftest-coverage"
18+
// CHECK: "-coverage-data-file" "[[PREFIX]]/t.gcda"
19+
// CHECK: "-coverage-notes-file" "[[PREFIX]]/t.gcno"
1620
// SHOULD-NOT: "-fcas-fs"
1721
// SHOULD-NOT: "-fcas-fs-working-directory"
1822
// SHOULD-NOT: "-I"

clang/test/CAS/fcas-include-tree-with-pch.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,14 @@
3737
// RUN: %clang @tu2.rsp -emit-llvm -o tree-rel.ll
3838
// RUN: diff -u source-rel.ll tree-rel.ll
3939

40+
// Check that -coverage-notes-file and -coverage-data-file are stripped
41+
// RUN: %clang -cc1depscan -o pch3.rsp -fdepscan=inline -fdepscan-include-tree -cc1-args \
42+
// RUN: -cc1 -emit-pch -x c-header prefix.h -I %t/inc -DCMD_MACRO=1 -fcas-path %t/cas \
43+
// RUN: -ftest-coverage -coverage-notes-file %t/pch.gcno -coverage-data-file %t/pch.gcda
44+
// RUN: FileCheck %s -check-prefix=COVERAGE -input-file %t/pch3.rsp
45+
// COVERAGE-NOT: -coverage-data-file
46+
// COVERAGE-NOT: -coverage-notes-file
47+
4048
//--- t1.c
4149
#if S2_MACRO
4250
#include "s2-link.h"

0 commit comments

Comments
 (0)