aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/Lex/PPMacroExpansion.cpp1
-rw-r--r--test/Lexer/has_feature_memory_sanitizer.cpp11
2 files changed, 12 insertions, 0 deletions
diff --git a/lib/Lex/PPMacroExpansion.cpp b/lib/Lex/PPMacroExpansion.cpp
index 941c2d47d0..d2f1b5f05d 100644
--- a/lib/Lex/PPMacroExpansion.cpp
+++ b/lib/Lex/PPMacroExpansion.cpp
@@ -780,6 +780,7 @@ static bool HasFeature(const Preprocessor &PP, const IdentifierInfo *II) {
.Case("cxx_exceptions", LangOpts.Exceptions)
.Case("cxx_rtti", LangOpts.RTTI)
.Case("enumerator_attributes", true)
+ .Case("memory_sanitizer", LangOpts.SanitizeMemory)
.Case("thread_sanitizer", LangOpts.SanitizeThread)
// Objective-C features
.Case("objc_arr", LangOpts.ObjCAutoRefCount) // FIXME: REMOVE?
diff --git a/test/Lexer/has_feature_memory_sanitizer.cpp b/test/Lexer/has_feature_memory_sanitizer.cpp
new file mode 100644
index 0000000000..3ebb9e1368
--- /dev/null
+++ b/test/Lexer/has_feature_memory_sanitizer.cpp
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -E -fsanitize=memory %s -o - | FileCheck --check-prefix=CHECK-MSAN %s
+// RUN: %clang_cc1 -E %s -o - | FileCheck --check-prefix=CHECK-NO-MSAN %s
+
+#if __has_feature(memory_sanitizer)
+int MemorySanitizerEnabled();
+#else
+int MemorySanitizerDisabled();
+#endif
+
+// CHECK-MSAN: MemorySanitizerEnabled
+// CHECK-NO-MSAN: MemorySanitizerDisabled