From: Evgeniy Stepanov Date: Thu, 20 Dec 2012 12:03:13 +0000 (+0000) Subject: Add __has_feature(memory_sanitizer). X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5c70ef4ae43dbfd501bedb8e8952fc3881527110;p=clang Add __has_feature(memory_sanitizer). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@170686 91177308-0d34-0410-b5e6-96231b3b80d8 --- 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