[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

llvm-svn: 342358
This commit is contained in:
Petr Hosek 2018-09-17 05:25:47 +00:00
parent 040ab65c53
commit 00f51c0904
2 changed files with 12 additions and 0 deletions

View File

@ -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)

View File

@ -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