Author: mgorny Date: Sun Sep 22 13:55:01 2019 New Revision: 372527 URL: http://llvm.org/viewvc/llvm-project?rev=372527&view=rev Log: [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 Added: cfe/trunk/test/Lexer/has_feature_leak_sanitizer.cpp Modified: cfe/trunk/include/clang/Basic/Features.def Modified: cfe/trunk/include/clang/Basic/Features.def URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Features.def?rev=372527&r1=372526&r2=372527&view=diff ============================================================================== --- cfe/trunk/include/clang/Basic/Features.def (original) +++ cfe/trunk/include/clang/Basic/Features.def Sun Sep 22 13:55:01 2019 @@ -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)) Added: cfe/trunk/test/Lexer/has_feature_leak_sanitizer.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Lexer/has_feature_leak_sanitizer.cpp?rev=372527&view=auto ============================================================================== --- cfe/trunk/test/Lexer/has_feature_leak_sanitizer.cpp (added) +++ cfe/trunk/test/Lexer/has_feature_leak_sanitizer.cpp Sun Sep 22 13:55:01 2019 @@ -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 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits