Skip to content
Permalink
Browse files

[clang] [Basic] Enable __has_feature(leak_sanitizer)

Add a 'leak_sanitizer' feature akin to existing '*_sanitizer' features
to let programmers switch code paths accounting for leak sanitizers
being enabled.

Differential Revision: https://reviews.llvm.org/D67719

llvm-svn: 372527
  • Loading branch information...
mgorny committed Sep 22, 2019
1 parent c4802de commit 96f35266a5d6f4497f87d22ff4a38320e8a8b4d9
Showing with 13 additions and 0 deletions.
  1. +2 −0 clang/include/clang/Basic/Features.def
  2. +11 −0 clang/test/Lexer/has_feature_leak_sanitizer.cpp
@@ -39,6 +39,8 @@
FEATURE(address_sanitizer,
LangOpts.Sanitize.hasOneOf(SanitizerKind::Address |
SanitizerKind::KernelAddress))
FEATURE(leak_sanitizer,
LangOpts.Sanitize.has(SanitizerKind::Leak))
FEATURE(hwaddress_sanitizer,
LangOpts.Sanitize.hasOneOf(SanitizerKind::HWAddress |
SanitizerKind::KernelHWAddress))
@@ -0,0 +1,11 @@
// RUN: %clang_cc1 -E -fsanitize=leak %s -o - | FileCheck --check-prefix=CHECK-LSAN %s
// RUN: %clang_cc1 -E %s -o - | FileCheck --check-prefix=CHECK-NO-LSAN %s

#if __has_feature(leak_sanitizer)
int LeakSanitizerEnabled();
#else
int LeakSanitizerDisabled();
#endif

// CHECK-LSAN: LeakSanitizerEnabled
// CHECK-NO-LSAN: LeakSanitizerDisabled

0 comments on commit 96f3526

Please sign in to comment.
You can’t perform that action at this time.