[PATCH] D67719: [clang] [Basic] Enable __has_feature(leak_sanitizer)

Michał Górny via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Sep 20 23:22:40 PDT 2019


mgorny updated this revision to Diff 221155.
mgorny added a comment.

Test added. Thanks for the suggestion!


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D67719/new/

https://reviews.llvm.org/D67719

Files:
  clang/include/clang/Basic/Features.def
  clang/test/Lexer/has_feature_leak_sanitizer.cpp


Index: clang/test/Lexer/has_feature_leak_sanitizer.cpp
===================================================================
--- /dev/null
+++ clang/test/Lexer/has_feature_leak_sanitizer.cpp
@@ -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
Index: clang/include/clang/Basic/Features.def
===================================================================
--- clang/include/clang/Basic/Features.def
+++ clang/include/clang/Basic/Features.def
@@ -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))


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D67719.221155.patch
Type: text/x-patch
Size: 1174 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190921/97e55642/attachment.bin>


More information about the cfe-commits mailing list