[cfe-commits] r145054 - in /cfe/trunk: include/clang/Basic/LangOptions.def include/clang/Frontend/CodeGenOptions.h lib/CodeGen/BackendUtil.cpp lib/Frontend/CompilerInvocation.cpp lib/Lex/PPMacroExpansion.cpp test/Lexer/has_feature_address_sanitizer.cpp
Kostya Serebryany
kcc at google.com
Mon Nov 21 17:28:36 PST 2011
Author: kcc
Date: Mon Nov 21 19:28:36 2011
New Revision: 145054
URL: http://llvm.org/viewvc/llvm-project?rev=145054&view=rev
Log:
implement __has_feature(address_sanitizer); also use LangOpts.AddressSanitizer instead of CodeGenOpts.AddressSanitizer
Added:
cfe/trunk/test/Lexer/has_feature_address_sanitizer.cpp
Modified:
cfe/trunk/include/clang/Basic/LangOptions.def
cfe/trunk/include/clang/Frontend/CodeGenOptions.h
cfe/trunk/lib/CodeGen/BackendUtil.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/lib/Lex/PPMacroExpansion.cpp
Modified: cfe/trunk/include/clang/Basic/LangOptions.def
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/LangOptions.def?rev=145054&r1=145053&r2=145054&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/LangOptions.def (original)
+++ cfe/trunk/include/clang/Basic/LangOptions.def Mon Nov 21 19:28:36 2011
@@ -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")
Modified: cfe/trunk/include/clang/Frontend/CodeGenOptions.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/CodeGenOptions.h?rev=145054&r1=145053&r2=145054&view=diff
==============================================================================
--- cfe/trunk/include/clang/Frontend/CodeGenOptions.h (original)
+++ cfe/trunk/include/clang/Frontend/CodeGenOptions.h Mon Nov 21 19:28:36 2011
@@ -35,7 +35,6 @@
Mixed = 2
};
- unsigned AddressSanitizer : 1; /// Enable AddressSanitizer.
unsigned AsmVerbose : 1; /// -dA, -fverbose-asm.
unsigned ObjCAutoRefCountExceptions : 1; /// Whether ARC should be EH-safe.
unsigned CUDAIsDevice : 1; /// Set when compiling for CUDA device.
@@ -152,7 +151,6 @@
public:
CodeGenOptions() {
- AddressSanitizer = 0;
AsmVerbose = 0;
CUDAIsDevice = 0;
CXAAtExit = 1;
Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/BackendUtil.cpp?rev=145054&r1=145053&r2=145054&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/BackendUtil.cpp (original)
+++ cfe/trunk/lib/CodeGen/BackendUtil.cpp Mon Nov 21 19:28:36 2011
@@ -147,7 +147,7 @@
addObjCARCOptPass);
}
- if (CodeGenOpts.AddressSanitizer) {
+ if (LangOpts.AddressSanitizer) {
PMBuilder.addExtension(PassManagerBuilder::EP_ScalarOptimizerLate,
addAddressSanitizerPass);
}
Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=145054&r1=145053&r2=145054&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Mon Nov 21 19:28:36 2011
@@ -153,8 +153,6 @@
Res.push_back("-dwarf-debug-flags");
Res.push_back(Opts.DwarfDebugFlags);
}
- if (Opts.AddressSanitizer)
- Res.push_back("-faddress-sanitizer");
if (Opts.ObjCRuntimeHasARC)
Res.push_back("-fobjc-runtime-has-arc");
if (Opts.ObjCRuntimeHasTerminate)
@@ -669,6 +667,8 @@
Res.push_back("-fpascal-strings");
if (Opts.CatchUndefined)
Res.push_back("-fcatch-undefined-behavior");
+ if (Opts.AddressSanitizer)
+ Res.push_back("-faddress-sanitizer");
if (Opts.WritableStrings)
Res.push_back("-fwritable-strings");
if (Opts.ConstStrings)
@@ -1069,7 +1069,6 @@
Opts.UnrollLoops = Args.hasArg(OPT_funroll_loops) ||
(Opts.OptimizationLevel > 1 && !Opts.OptimizeSize);
- Opts.AddressSanitizer = Args.hasArg(OPT_faddress_sanitizer);
Opts.AsmVerbose = Args.hasArg(OPT_masm_verbose);
Opts.ObjCAutoRefCountExceptions = Args.hasArg(OPT_fobjc_arc_exceptions);
Opts.ObjCRuntimeHasARC = Args.hasArg(OPT_fobjc_runtime_has_arc);
@@ -1812,6 +1811,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);
Modified: cfe/trunk/lib/Lex/PPMacroExpansion.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPMacroExpansion.cpp?rev=145054&r1=145053&r2=145054&view=diff
==============================================================================
--- cfe/trunk/lib/Lex/PPMacroExpansion.cpp (original)
+++ cfe/trunk/lib/Lex/PPMacroExpansion.cpp Mon Nov 21 19:28:36 2011
@@ -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)
Added: cfe/trunk/test/Lexer/has_feature_address_sanitizer.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Lexer/has_feature_address_sanitizer.cpp?rev=145054&view=auto
==============================================================================
--- cfe/trunk/test/Lexer/has_feature_address_sanitizer.cpp (added)
+++ cfe/trunk/test/Lexer/has_feature_address_sanitizer.cpp Mon Nov 21 19:28:36 2011
@@ -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
More information about the cfe-commits
mailing list