Hello,
Please review the patch which implements __has_feature(address_sanitizer).
Adding this feature has been discussed on this list previously:
http://lists.cs.uiuc.edu/pipermail/cfe-commits/Week-of-Mon-20111114/049252.html
http://codereview.appspot.com/5430043
Thanks,
--kcc
Index: test/Lexer/has_feature_address_sanitizer.cpp
===================================================================
--- test/Lexer/has_feature_address_sanitizer.cpp (revision 0)
+++ test/Lexer/has_feature_address_sanitizer.cpp (revision 0)
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -E -faddress-sanitizer %s -o - | FileCheck --check-prefix=CHECK-ASAN %s
+// RUN: %clang_cc1 -E %s -o - | FileCheck --check-prefix=CHECK-NO-ASAN %s
+
+#if __has_feature(address_sanitizer)
+int AddressSanitizerEnabled();
+#else
+int AddressSanitizerDisabled();
+#endif
+
+// CHECK-ASAN: AddressSanitizerEnabled
+// CHECK-NO-ASAN: AddressSanitizerDisabled
Index: include/clang/Basic/LangOptions.def
===================================================================
--- include/clang/Basic/LangOptions.def (revision 145044)
+++ include/clang/Basic/LangOptions.def (working copy)
@@ -121,6 +121,7 @@
BENIGN_LANGOPT(InlineVisibilityHidden , 1, 0, "hidden default visibility for inline C++ methods")
BENIGN_LANGOPT(ParseUnknownAnytype, 1, 0, "__unknown_anytype")
BENIGN_LANGOPT(DebuggerSupport , 1, 0, "debugger support")
+BENIGN_LANGOPT(AddressSanitizer , 1, 0, "AddressSanitizer enabled")
BENIGN_LANGOPT(SpellChecking , 1, 1, "spell-checking")
LANGOPT(SinglePrecisionConstants , 1, 0, "treating double-precision floating point constants as single precision constants")
Index: lib/Frontend/CompilerInvocation.cpp
===================================================================
--- lib/Frontend/CompilerInvocation.cpp (revision 145044)
+++ lib/Frontend/CompilerInvocation.cpp (working copy)
@@ -1806,6 +1806,7 @@
Opts.FakeAddressSpaceMap = Args.hasArg(OPT_ffake_address_space_map);
Opts.ParseUnknownAnytype = Args.hasArg(OPT_funknown_anytype);
Opts.DebuggerSupport = Args.hasArg(OPT_fdebugger_support);
+ Opts.AddressSanitizer = Args.hasArg(OPT_faddress_sanitizer);
Opts.ApplePragmaPack = Args.hasArg(OPT_fapple_pragma_pack);
Opts.CurrentModule = Args.getLastArgValue(OPT_fmodule_name);
Index: lib/Lex/PPMacroExpansion.cpp
===================================================================
--- lib/Lex/PPMacroExpansion.cpp (revision 145044)
+++ lib/Lex/PPMacroExpansion.cpp (working copy)
@@ -583,6 +583,7 @@
const LangOptions &LangOpts = PP.getLangOptions();
return llvm::StringSwitch<bool>(II->getName())
+ .Case("address_sanitizer", LangOpts.AddressSanitizer)
.Case("attribute_analyzer_noreturn", true)
.Case("attribute_availability", true)
.Case("attribute_cf_returns_not_retained", true)
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits