r342358 - [Lexer] Add xray_instrument feature

Petr Hosek via cfe-commits cfe-commits at lists.llvm.org
Sun Sep 16 22:25:47 PDT 2018


Author: phosek
Date: Sun Sep 16 22:25:47 2018
New Revision: 342358

URL: http://llvm.org/viewvc/llvm-project?rev=342358&view=rev
Log:
[Lexer] Add xray_instrument feature

This can be used to detect whether the code is being built with XRay
instrumentation using the __has_feature(xray_instrument) predicate.

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

Added:
    cfe/trunk/test/Lexer/has_feature_xray_instrument.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=342358&r1=342357&r2=342358&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/Features.def (original)
+++ cfe/trunk/include/clang/Basic/Features.def Sun Sep 16 22:25:47 2018
@@ -37,6 +37,7 @@ FEATURE(address_sanitizer,
 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)

Added: cfe/trunk/test/Lexer/has_feature_xray_instrument.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Lexer/has_feature_xray_instrument.cpp?rev=342358&view=auto
==============================================================================
--- cfe/trunk/test/Lexer/has_feature_xray_instrument.cpp (added)
+++ cfe/trunk/test/Lexer/has_feature_xray_instrument.cpp Sun Sep 16 22:25:47 2018
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -E -fxray-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




More information about the cfe-commits mailing list