[PATCH] D52159: [Lexer] Add xray_instrument feature
Petr Hosek via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sun Sep 16 17:38:08 PDT 2018
phosek created this revision.
phosek added reviewers: dberris, echristo.
Herald added subscribers: Sanitizers, llvm-commits.
This can be used to detect whether the code is being built with XRay
instrumentation using the __has_feature(xray_instrument) predicate
Repository:
rCRT Compiler Runtime
https://reviews.llvm.org/D52159
Files:
clang/include/clang/Basic/Features.def
clang/test/Lexer/has_feature_xray_instrument.cpp
Index: clang/test/Lexer/has_feature_xray_instrument.cpp
===================================================================
--- /dev/null
+++ clang/test/Lexer/has_feature_xray_instrument.cpp
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -E -fsanitize=xray-instrument %s -o - | FileCheck --check-prefix=CHECK-XRAY %s
+// RUN: %clang_cc1 -E %s -o - | FileCheck --check-prefix=CHECK-NO-XRAY %s
+
+#if __has_feature(xray_instrument)
+int XRayInstrumentEnabled();
+#else
+int XRayInstrumentDisabled();
+#endif
+
+// CHECK-XRAY: XRayInstrumentEnabled
+// CHECK-NO-XRAY: XRayInstrumentDisabled
Index: clang/include/clang/Basic/Features.def
===================================================================
--- clang/include/clang/Basic/Features.def
+++ clang/include/clang/Basic/Features.def
@@ -37,6 +37,7 @@
FEATURE(hwaddress_sanitizer,
LangOpts.Sanitize.hasOneOf(SanitizerKind::HWAddress |
SanitizerKind::KernelHWAddress))
+FEATURE(xray_instrument, LangOpts.XRayInstrument)
FEATURE(assume_nonnull, true)
FEATURE(attribute_analyzer_noreturn, true)
FEATURE(attribute_availability, true)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D52159.165704.patch
Type: text/x-patch
Size: 1124 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180917/a2d98490/attachment.bin>
More information about the llvm-commits
mailing list