[clang] fb14941 - [clang][rtsan] Add realtime_sanitizer to Features.def (#106650)

via cfe-commits cfe-commits at lists.llvm.org
Fri Sep 6 10:46:50 PDT 2024


Author: Chris Apple
Date: 2024-09-06T10:46:47-07:00
New Revision: fb1494137e551448d8742d5e6367bf62e923598d

URL: https://github.com/llvm/llvm-project/commit/fb1494137e551448d8742d5e6367bf62e923598d
DIFF: https://github.com/llvm/llvm-project/commit/fb1494137e551448d8742d5e6367bf62e923598d.diff

LOG: [clang][rtsan] Add realtime_sanitizer to Features.def (#106650)

Allows us to introduce the scoped disabler in #106736

Added: 
    clang/test/Lexer/has_feature_realtime_sanitizer.cpp

Modified: 
    clang/include/clang/Basic/Features.def

Removed: 
    


################################################################################
diff  --git a/clang/include/clang/Basic/Features.def b/clang/include/clang/Basic/Features.def
index 10538f555b418e..7f5d26118bdc71 100644
--- a/clang/include/clang/Basic/Features.def
+++ b/clang/include/clang/Basic/Features.def
@@ -54,6 +54,8 @@ FEATURE(memtag_globals,
 FEATURE(xray_instrument, LangOpts.XRayInstrument)
 FEATURE(undefined_behavior_sanitizer,
         LangOpts.Sanitize.hasOneOf(SanitizerKind::Undefined))
+FEATURE(realtime_sanitizer,
+        LangOpts.Sanitize.has(SanitizerKind::Realtime))
 FEATURE(coverage_sanitizer, LangOpts.SanitizeCoverage)
 FEATURE(assume_nonnull, true)
 FEATURE(attribute_analyzer_noreturn, true)

diff  --git a/clang/test/Lexer/has_feature_realtime_sanitizer.cpp b/clang/test/Lexer/has_feature_realtime_sanitizer.cpp
new file mode 100644
index 00000000000000..76febeb6473a4b
--- /dev/null
+++ b/clang/test/Lexer/has_feature_realtime_sanitizer.cpp
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -E -fsanitize=realtime %s -o - | FileCheck --check-prefix=CHECK-RTSAN %s
+// RUN: %clang_cc1 -E  %s -o - | FileCheck --check-prefix=CHECK-NO-RTSAN %s
+
+#if __has_feature(realtime_sanitizer)
+int RealtimeSanitizerEnabled();
+#else
+int RealtimeSanitizerDisabled();
+#endif
+
+// CHECK-RTSAN: RealtimeSanitizerEnabled
+
+// CHECK-NO-RTSAN: RealtimeSanitizerDisabled


        


More information about the cfe-commits mailing list