From ce2e77c771c8c564c7d37825b318a2195294bf8b Mon Sep 17 00:00:00 2001 From: Alexey Samsonov Date: Wed, 11 Mar 2015 23:34:25 +0000 Subject: [PATCH] Add deprecation notice for -f(no-)sanitize-recover flags. These flags should be replaced with corresponding -f(no-)sanitize-recover= flags. llvm-svn: 231983 --- clang/include/clang/Basic/DiagnosticDriverKinds.td | 2 ++ clang/lib/Driver/SanitizerArgs.cpp | 9 +++++++-- clang/test/Driver/fsanitize.c | 9 +++++++-- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/clang/include/clang/Basic/DiagnosticDriverKinds.td b/clang/include/clang/Basic/DiagnosticDriverKinds.td index 76853d8..9a055b8 100644 --- a/clang/include/clang/Basic/DiagnosticDriverKinds.td +++ b/clang/include/clang/Basic/DiagnosticDriverKinds.td @@ -142,6 +142,8 @@ def warn_drv_empty_joined_argument : Warning< InGroup; def warn_drv_clang_unsupported : Warning< "the clang compiler does not support '%0'">; +def warn_drv_deprecated_arg : Warning< + "argument '%0' is deprecated, use '%1' instead">, InGroup; def warn_drv_assuming_mfloat_abi_is : Warning< "unknown platform, assuming -mfloat-abi=%0">; def warn_ignoring_ftabstop_value : Warning< diff --git a/clang/lib/Driver/SanitizerArgs.cpp b/clang/lib/Driver/SanitizerArgs.cpp index 137f122..557b62f 100644 --- a/clang/lib/Driver/SanitizerArgs.cpp +++ b/clang/lib/Driver/SanitizerArgs.cpp @@ -251,12 +251,13 @@ SanitizerArgs::SanitizerArgs(const ToolChain &TC, uint64_t RecoverableKinds = RecoverableByDefault; uint64_t DiagnosedUnrecoverableKinds = 0; for (const auto *Arg : Args) { + const char *DeprecatedReplacement = nullptr; if (Arg->getOption().matches(options::OPT_fsanitize_recover)) { - // FIXME: Add deprecation notice, and then remove this flag. + DeprecatedReplacement = "-fsanitize-recover=undefined,integer"; RecoverableKinds |= expandGroups(LegacyFsanitizeRecoverMask); Arg->claim(); } else if (Arg->getOption().matches(options::OPT_fno_sanitize_recover)) { - // FIXME: Add deprecation notice, and then remove this flag. + DeprecatedReplacement = "-fno-sanitize-recover=undefined,integer"; RecoverableKinds &= ~expandGroups(LegacyFsanitizeRecoverMask); Arg->claim(); } else if (Arg->getOption().matches(options::OPT_fsanitize_recover_EQ)) { @@ -277,6 +278,10 @@ SanitizerArgs::SanitizerArgs(const ToolChain &TC, RecoverableKinds &= ~expandGroups(parseArgValues(D, Arg, true)); Arg->claim(); } + if (DeprecatedReplacement) { + D.Diag(diag::warn_drv_deprecated_arg) << Arg->getAsString(Args) + << DeprecatedReplacement; + } } RecoverableKinds &= Kinds; RecoverableKinds &= ~Unrecoverable; diff --git a/clang/test/Driver/fsanitize.c b/clang/test/Driver/fsanitize.c index e22201f..b4cbc39 100644 --- a/clang/test/Driver/fsanitize.c +++ b/clang/test/Driver/fsanitize.c @@ -142,10 +142,10 @@ // RUN: %clang -target x86_64-linux-gnu %s -fsanitize=undefined -### 2>&1 | FileCheck %s --check-prefix=CHECK-RECOVER // RUN: %clang -target x86_64-linux-gnu %s -fsanitize=undefined -fsanitize-recover -### 2>&1 | FileCheck %s --check-prefix=CHECK-RECOVER // RUN: %clang -target x86_64-linux-gnu %s -fsanitize=undefined -fsanitize-recover=all -### 2>&1 | FileCheck %s --check-prefix=CHECK-RECOVER -// RUN: %clang -target x86_64-linux-gnu %s -fsanitize=undefined -fno-sanitize-recover -### 2>&1 | FileCheck %s --check-prefix=CHECK-NO-RECOVER +// RUN: %clang -target x86_64-linux-gnu %s -fsanitize=undefined -fno-sanitize-recover=undefined -### 2>&1 | FileCheck %s --check-prefix=CHECK-NO-RECOVER // RUN: %clang -target x86_64-linux-gnu %s -fsanitize=undefined -fno-sanitize-recover=all -fsanitize-recover=thread -### 2>&1 | FileCheck %s --check-prefix=CHECK-NO-RECOVER // RUN: %clang -target x86_64-linux-gnu %s -fsanitize=undefined -fno-sanitize-recover -fsanitize-recover=undefined -### 2>&1 | FileCheck %s --check-prefix=CHECK-RECOVER -// RUN: %clang -target x86_64-linux-gnu %s -fsanitize=undefined -fsanitize-recover -fno-sanitize-recover -### 2>&1 | FileCheck %s --check-prefix=CHECK-NO-RECOVER +// RUN: %clang -target x86_64-linux-gnu %s -fsanitize=undefined -fsanitize-recover=all -fno-sanitize-recover=undefined -### 2>&1 | FileCheck %s --check-prefix=CHECK-NO-RECOVER // RUN: %clang -target x86_64-linux-gnu %s -fsanitize=undefined -fno-sanitize-recover=all -fsanitize-recover=object-size,shift-base -### 2>&1 | FileCheck %s --check-prefix=CHECK-PARTIAL-RECOVER // CHECK-RECOVER: "-fsanitize-recover={{((signed-integer-overflow|integer-divide-by-zero|float-divide-by-zero|function|shift-base|shift-exponent|vla-bound|alignment|null|vptr|object-size|float-cast-overflow|array-bounds|enum|bool|returns-nonnull-attribute|nonnull-attribute),?){17}"}} @@ -156,6 +156,11 @@ // CHECK-DIAG-RECOVER: unsupported argument 'foobar' to option 'fsanitize-recover=' // CHECK-DIAG-RECOVER: unsupported argument 'address,unreachable' to option 'fsanitize-recover=' +// RUN: %clang -target x86_64-linux-gnu %s -fsanitize=undefined -fsanitize-recover -fno-sanitize-recover -### 2>&1 | FileCheck %s --check-prefix=CHECK-DEPRECATED-RECOVER +// CHECK-DEPRECATED-RECOVER: argument '-fsanitize-recover' is deprecated, use '-fsanitize-recover=undefined,integer' instead +// CHECK-DEPRECATED-RECOVER: argument '-fno-sanitize-recover' is deprecated, use '-fno-sanitize-recover=undefined,integer' instead +// CHECK-DEPRECATED-RECOVER-NOT: is deprecated + // RUN: %clang -target x86_64-linux-gnu -fsanitize=leak %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SANL // CHECK-SANL: "-fsanitize=leak" -- 2.7.4