Skip to content

Commit 8955efc

Browse files
committed
[sanitizer-coverage] add a deprecation warning to the old sanitizer-coverage flag combinations
llvm-svn: 301994
1 parent 40d067c commit 8955efc

File tree

2 files changed

+22
-16
lines changed

2 files changed

+22
-16
lines changed

clang/lib/Driver/SanitizerArgs.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -511,7 +511,6 @@ SanitizerArgs::SanitizerArgs(const ToolChain &TC,
511511
<< "-fsanitize-coverage=edge";
512512
// Basic block tracing and 8-bit counters require some type of coverage
513513
// enabled.
514-
int CoverageTypes = CoverageFunc | CoverageBB | CoverageEdge;
515514
if (CoverageFeatures & CoverageTraceBB)
516515
D.Diag(clang::diag::warn_drv_deprecated_arg)
517516
<< "-fsanitize-coverage=trace-bb"
@@ -520,9 +519,18 @@ SanitizerArgs::SanitizerArgs(const ToolChain &TC,
520519
D.Diag(clang::diag::warn_drv_deprecated_arg)
521520
<< "-fsanitize-coverage=8bit-counters"
522521
<< "-fsanitize-coverage=trace-pc-guard";
522+
523+
int InsertionPointTypes = CoverageFunc | CoverageBB | CoverageEdge;
524+
if ((CoverageFeatures & InsertionPointTypes) &&
525+
!(CoverageFeatures &(CoverageTracePC | CoverageTracePCGuard))) {
526+
D.Diag(clang::diag::warn_drv_deprecated_arg)
527+
<< "-fsanitize-coverage=[func|bb|edge]"
528+
<< "-fsanitize-coverage=[func|bb|edge],[trace-pc-guard|trace-pc]";
529+
}
530+
523531
// trace-pc w/o func/bb/edge implies edge.
524532
if ((CoverageFeatures & (CoverageTracePC | CoverageTracePCGuard)) &&
525-
!(CoverageFeatures & CoverageTypes))
533+
!(CoverageFeatures & InsertionPointTypes))
526534
CoverageFeatures |= CoverageEdge;
527535

528536
if (AllAddedKinds & Address) {

clang/test/Driver/fsanitize-coverage.c

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,13 @@
44
// CHECK-SANITIZE-COVERAGE-0-NOT: fsanitize-coverage-type
55
// CHECK-SANITIZE-COVERAGE-0: -fsanitize=address
66

7-
// RUN: %clang -target x86_64-linux-gnu -fsanitize=address -fsanitize-coverage=func %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SANITIZE-COVERAGE-FUNC
8-
// RUN: %clang -target x86_64-linux-gnu -fsanitize=memory -fsanitize-coverage=func %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SANITIZE-COVERAGE-FUNC
9-
// RUN: %clang -target x86_64-linux-gnu -fsanitize=leak -fsanitize-coverage=func %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SANITIZE-COVERAGE-FUNC
10-
// RUN: %clang -target x86_64-linux-gnu -fsanitize=undefined -fsanitize-coverage=func %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SANITIZE-COVERAGE-FUNC
11-
// RUN: %clang -target x86_64-linux-gnu -fsanitize=bool -fsanitize-coverage=func %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SANITIZE-COVERAGE-FUNC
12-
// RUN: %clang -target x86_64-linux-gnu -fsanitize=dataflow -fsanitize-coverage=func %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SANITIZE-COVERAGE-FUNC
7+
// RUN: %clang -target x86_64-linux-gnu -fsanitize=address -fsanitize-coverage=func,trace-pc %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SANITIZE-COVERAGE-FUNC
8+
// RUN: %clang -target x86_64-linux-gnu -fsanitize=memory -fsanitize-coverage=func,trace-pc %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SANITIZE-COVERAGE-FUNC
9+
// RUN: %clang -target x86_64-linux-gnu -fsanitize=leak -fsanitize-coverage=func,trace-pc %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SANITIZE-COVERAGE-FUNC
10+
// RUN: %clang -target x86_64-linux-gnu -fsanitize=undefined -fsanitize-coverage=func,trace-pc %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SANITIZE-COVERAGE-FUNC
11+
// RUN: %clang -target x86_64-linux-gnu -fsanitize=bool -fsanitize-coverage=func,trace-pc %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SANITIZE-COVERAGE-FUNC
12+
// RUN: %clang -target x86_64-linux-gnu -fsanitize=dataflow -fsanitize-coverage=func,trace-pc %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SANITIZE-COVERAGE-FUNC
13+
// RUN: %clang -target x86_64-linux-gnu -fsanitize-coverage=func,trace-pc %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SANITIZE-COVERAGE-FUNC
1314
// CHECK-SANITIZE-COVERAGE-FUNC: fsanitize-coverage-type=1
1415

1516
// RUN: %clang -target x86_64-linux-gnu -fsanitize=address -fsanitize-coverage=bb %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SANITIZE-COVERAGE-BB
@@ -25,13 +26,10 @@
2526
// RUN: %clang -target x86_64-linux-gnu -fsanitize=address -fsanitize-coverage=1 %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SANITIZE-COVERAGE-1
2627
// CHECK-SANITIZE-COVERAGE-1: warning: argument '-fsanitize-coverage=1' is deprecated, use '-fsanitize-coverage=trace-pc-guard' instead
2728

28-
// RUN: %clang -target x86_64-linux-gnu -fsanitize=thread -fsanitize-coverage=func %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SANITIZE-COVERAGE-UNUSED
29-
// RUN: %clang -target x86_64-linux-gnu -fsanitize-coverage=func %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SANITIZE-COVERAGE-FUNC
30-
// CHECK-SANITIZE-COVERAGE-UNUSED: argument unused during compilation: '-fsanitize-coverage=func'
31-
// CHECK-SANITIZE-COVERAGE-UNUSED-NOT: -fsanitize-coverage-type=1
32-
33-
// RUN: %clang -target x86_64-linux-gnu -fsanitize=address -fsanitize-coverage=func -fno-sanitize=address %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SANITIZE-COVERAGE-SAN-DISABLED
34-
// CHECK-SANITIZE-COVERAGE-SAN-DISABLED-NOT: argument unused
29+
// RUN: %clang -target x86_64-linux-gnu -fsanitize=address -fsanitize-coverage=func %s -### 2>&1 | FileCheck %s --check-prefix=CHECK_FUNC_BB_EDGE_DEPRECATED
30+
// RUN: %clang -target x86_64-linux-gnu -fsanitize=address -fsanitize-coverage=bb %s -### 2>&1 | FileCheck %s --check-prefix=CHECK_FUNC_BB_EDGE_DEPRECATED
31+
// RUN: %clang -target x86_64-linux-gnu -fsanitize=address -fsanitize-coverage=edge %s -### 2>&1 | FileCheck %s --check-prefix=CHECK_FUNC_BB_EDGE_DEPRECATED
32+
// CHECK_FUNC_BB_EDGE_DEPRECATED: warning: argument '-fsanitize-coverage=[func|bb|edge]' is deprecated, use '-fsanitize-coverage=[func|bb|edge],[trace-pc-guard|trace-pc]' instead
3533

3634
// RUN: %clang -target x86_64-linux-gnu -fsanitize=address -fsanitize-coverage=edge,indirect-calls,trace-pc,trace-cmp,trace-div,trace-gep %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SANITIZE-COVERAGE-FEATURES
3735
// CHECK-SANITIZE-COVERAGE-FEATURES: -fsanitize-coverage-type=3
@@ -82,7 +80,7 @@
8280
// CHECK-EXTEND-LEGACY: -fsanitize-coverage-type=1
8381
// CHECK-EXTEND-LEGACY: -fsanitize-coverage-trace-cmp
8482

85-
// RUN: %clang_cl --target=i386-pc-win32 -fsanitize=address -fsanitize-coverage=func -c -### -- %s 2>&1 | FileCheck %s -check-prefix=CLANG-CL-COVERAGE
83+
// RUN: %clang_cl --target=i386-pc-win32 -fsanitize=address -fsanitize-coverage=func,trace-pc-guard -c -### -- %s 2>&1 | FileCheck %s -check-prefix=CLANG-CL-COVERAGE
8684
// CLANG-CL-COVERAGE-NOT: error:
8785
// CLANG-CL-COVERAGE-NOT: warning:
8886
// CLANG-CL-COVERAGE-NOT: argument unused

0 commit comments

Comments
 (0)