This revision was automatically updated to reflect the committed changes.
Closed by commit rL342793: [Lexer] Add udefined_behavior_sanitizer feature 
(authored by leonardchan, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D52386?vs=166585&id=166587#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D52386

Files:
  cfe/trunk/include/clang/Basic/Features.def
  cfe/trunk/test/Lexer/has_feature_undefined_behavior_sanitizer.cpp


Index: cfe/trunk/include/clang/Basic/Features.def
===================================================================
--- cfe/trunk/include/clang/Basic/Features.def
+++ cfe/trunk/include/clang/Basic/Features.def
@@ -38,6 +38,8 @@
         LangOpts.Sanitize.hasOneOf(SanitizerKind::HWAddress |
                                    SanitizerKind::KernelHWAddress))
 FEATURE(xray_instrument, LangOpts.XRayInstrument)
+FEATURE(undefined_behavior_sanitizer,
+        LangOpts.Sanitize.hasOneOf(SanitizerKind::Undefined))
 FEATURE(assume_nonnull, true)
 FEATURE(attribute_analyzer_noreturn, true)
 FEATURE(attribute_availability, true)
Index: cfe/trunk/test/Lexer/has_feature_undefined_behavior_sanitizer.cpp
===================================================================
--- cfe/trunk/test/Lexer/has_feature_undefined_behavior_sanitizer.cpp
+++ cfe/trunk/test/Lexer/has_feature_undefined_behavior_sanitizer.cpp
@@ -0,0 +1,13 @@
+// RUN: %clang -E -fsanitize=undefined %s -o - | FileCheck 
--check-prefix=CHECK-UBSAN %s
+// RUN: %clang -E -fsanitize=alignment %s -o - | FileCheck 
--check-prefix=CHECK-ALIGNMENT %s
+// RUN: %clang -E  %s -o - | FileCheck --check-prefix=CHECK-NO-UBSAN %s
+
+#if __has_feature(undefined_behavior_sanitizer)
+int UBSanEnabled();
+#else
+int UBSanDisabled();
+#endif
+
+// CHECK-UBSAN: UBSanEnabled
+// CHECK-ALIGNMENT: UBSanEnabled
+// CHECK-NO-UBSAN: UBSanDisabled


Index: cfe/trunk/include/clang/Basic/Features.def
===================================================================
--- cfe/trunk/include/clang/Basic/Features.def
+++ cfe/trunk/include/clang/Basic/Features.def
@@ -38,6 +38,8 @@
         LangOpts.Sanitize.hasOneOf(SanitizerKind::HWAddress |
                                    SanitizerKind::KernelHWAddress))
 FEATURE(xray_instrument, LangOpts.XRayInstrument)
+FEATURE(undefined_behavior_sanitizer,
+        LangOpts.Sanitize.hasOneOf(SanitizerKind::Undefined))
 FEATURE(assume_nonnull, true)
 FEATURE(attribute_analyzer_noreturn, true)
 FEATURE(attribute_availability, true)
Index: cfe/trunk/test/Lexer/has_feature_undefined_behavior_sanitizer.cpp
===================================================================
--- cfe/trunk/test/Lexer/has_feature_undefined_behavior_sanitizer.cpp
+++ cfe/trunk/test/Lexer/has_feature_undefined_behavior_sanitizer.cpp
@@ -0,0 +1,13 @@
+// RUN: %clang -E -fsanitize=undefined %s -o - | FileCheck --check-prefix=CHECK-UBSAN %s
+// RUN: %clang -E -fsanitize=alignment %s -o - | FileCheck --check-prefix=CHECK-ALIGNMENT %s
+// RUN: %clang -E  %s -o - | FileCheck --check-prefix=CHECK-NO-UBSAN %s
+
+#if __has_feature(undefined_behavior_sanitizer)
+int UBSanEnabled();
+#else
+int UBSanDisabled();
+#endif
+
+// CHECK-UBSAN: UBSanEnabled
+// CHECK-ALIGNMENT: UBSanEnabled
+// CHECK-NO-UBSAN: UBSanDisabled
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to