mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2024-12-13 19:24:21 +00:00
Add -f[no-]address-sanitizer flag
llvm-svn: 144800
This commit is contained in:
parent
10f4d06b81
commit
8855ff61cb
@ -114,6 +114,8 @@ def fdebug_compilation_dir : Separate<"-fdebug-compilation-dir">,
|
||||
HelpText<"The compilation directory to embed in the debug info.">;
|
||||
def dwarf_debug_flags : Separate<"-dwarf-debug-flags">,
|
||||
HelpText<"The string to embed in the Dwarf debug flags record.">;
|
||||
def faddress_sanitizer: Flag<"-faddress-sanitizer">,
|
||||
HelpText<"Enable AddressSanitizer instrumentation (memory error detection)">;
|
||||
def fforbid_guard_variables : Flag<"-fforbid-guard-variables">,
|
||||
HelpText<"Emit an error if a C++ static local initializer would need a guard variable">;
|
||||
def g : Flag<"-g">, HelpText<"Generate source level debug information">;
|
||||
|
@ -262,6 +262,8 @@ def faccess_control : Flag<"-faccess-control">, Group<f_Group>;
|
||||
def fallow_unsupported : Flag<"-fallow-unsupported">, Group<f_Group>;
|
||||
def fapple_kext : Flag<"-fapple-kext">, Group<f_Group>;
|
||||
def fapple_pragma_pack : Flag<"-fapple-pragma-pack">, Group<f_Group>;
|
||||
def faddress_sanitizer : Flag<"-faddress-sanitizer">, Group<f_Group>;
|
||||
def fno_address_sanitizer : Flag<"-fno-address-sanitizer">, Group<f_Group>;
|
||||
def fasm : Flag<"-fasm">, Group<f_Group>;
|
||||
|
||||
def fasm_blocks : Flag<"-fasm-blocks">, Group<f_Group>;
|
||||
|
@ -35,6 +35,7 @@ public:
|
||||
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.
|
||||
@ -151,6 +152,7 @@ public:
|
||||
|
||||
public:
|
||||
CodeGenOptions() {
|
||||
AddressSanitizer = 0;
|
||||
AsmVerbose = 0;
|
||||
CUDAIsDevice = 0;
|
||||
CXAAtExit = 1;
|
||||
|
@ -115,6 +115,11 @@ static void addObjCARCOptPass(const PassManagerBuilder &Builder, PassManagerBase
|
||||
PM.add(createObjCARCOptPass());
|
||||
}
|
||||
|
||||
static void addAddressSanitizerPass(const PassManagerBuilder &Builder,
|
||||
PassManagerBase &PM) {
|
||||
PM.add(createAddressSanitizerPass());
|
||||
}
|
||||
|
||||
void EmitAssemblyHelper::CreatePasses() {
|
||||
unsigned OptLevel = CodeGenOpts.OptimizationLevel;
|
||||
CodeGenOptions::InliningMethod Inlining = CodeGenOpts.Inlining;
|
||||
@ -141,6 +146,11 @@ void EmitAssemblyHelper::CreatePasses() {
|
||||
PMBuilder.addExtension(PassManagerBuilder::EP_ScalarOptimizerLate,
|
||||
addObjCARCOptPass);
|
||||
}
|
||||
|
||||
if (CodeGenOpts.AddressSanitizer) {
|
||||
PMBuilder.addExtension(PassManagerBuilder::EP_ScalarOptimizerLate,
|
||||
addAddressSanitizerPass);
|
||||
}
|
||||
|
||||
// Figure out TargetLibraryInfo.
|
||||
Triple TargetTriple(TheModule->getTargetTriple());
|
||||
|
@ -1701,6 +1701,10 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
|
||||
if (getToolChain().SupportsProfiling())
|
||||
Args.AddLastArg(CmdArgs, options::OPT_pg);
|
||||
|
||||
if (Args.hasFlag(options::OPT_faddress_sanitizer,
|
||||
options::OPT_fno_address_sanitizer, false))
|
||||
CmdArgs.push_back("-faddress-sanitizer");
|
||||
|
||||
// -flax-vector-conversions is default.
|
||||
if (!Args.hasFlag(options::OPT_flax_vector_conversions,
|
||||
options::OPT_fno_lax_vector_conversions))
|
||||
|
@ -139,6 +139,8 @@ static void CodeGenOptsToArgs(const CodeGenOptions &Opts,
|
||||
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)
|
||||
@ -1049,6 +1051,7 @@ static void ParseCodeGenArgs(CodeGenOptions &Opts, ArgList &Args, InputKind IK,
|
||||
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);
|
||||
|
Loading…
Reference in New Issue
Block a user