From: Petr Hosek Date: Mon, 17 Sep 2018 05:25:47 +0000 (+0000) Subject: [Lexer] Add xray_instrument feature X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=6df2955606d2e2bb8924c626c88d8beb7e424475;p=clang [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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@342358 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/Basic/Features.def b/include/clang/Basic/Features.def index 05c5a5b826..f816d1894e 100644 --- a/include/clang/Basic/Features.def +++ b/include/clang/Basic/Features.def @@ -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) diff --git a/test/Lexer/has_feature_xray_instrument.cpp b/test/Lexer/has_feature_xray_instrument.cpp new file mode 100644 index 0000000000..cd2750d77f --- /dev/null +++ b/test/Lexer/has_feature_xray_instrument.cpp @@ -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