[PATCH] D52386: [Lexer] Add udefined_behavior_sanitizer feature

Leonard Chan via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 21 18:04:54 PDT 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rC342793: [Lexer] Add udefined_behavior_sanitizer feature (authored by leonardchan, committed by ).

Repository:
  rL LLVM

https://reviews.llvm.org/D52386

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


Index: include/clang/Basic/Features.def
===================================================================
--- include/clang/Basic/Features.def
+++ 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: test/Lexer/has_feature_undefined_behavior_sanitizer.cpp
===================================================================
--- test/Lexer/has_feature_undefined_behavior_sanitizer.cpp
+++ 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


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D52386.166588.patch
Type: text/x-patch
Size: 1333 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180922/23d532d2/attachment.bin>


More information about the llvm-commits mailing list