]> granicus.if.org Git - clang/commitdiff
Add __has_feature(memory_sanitizer).
authorEvgeniy Stepanov <eugeni.stepanov@gmail.com>
Thu, 20 Dec 2012 12:03:13 +0000 (12:03 +0000)
committerEvgeniy Stepanov <eugeni.stepanov@gmail.com>
Thu, 20 Dec 2012 12:03:13 +0000 (12:03 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@170686 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Lex/PPMacroExpansion.cpp
test/Lexer/has_feature_memory_sanitizer.cpp [new file with mode: 0644]

index 941c2d47d09b63c53a863d1a9874b72fcae619bc..d2f1b5f05d74aa2e1486cf2e5675706f74d45d39 100644 (file)
@@ -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 (file)
index 0000000..3ebb9e1
--- /dev/null
@@ -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