[asan] Add basic support for Address Sanitizer function instrumentation

ASan allows to catch and diagnose memory corruption errors, which are possible
when using unsafe pointers.

This patch introduces a new driver/frontend option -sanitize=address to enable
ASan. When option is passed in, the ASan llvm passes will be turned on and
all functions will gain SanitizeAddress llvm attribute.
This commit is contained in:
zaks
2016-02-24 09:45:38 -08:00
parent f049c24a02
commit ef925f8fb3
15 changed files with 234 additions and 2 deletions

View File

@@ -15,6 +15,7 @@
#include "swift/Strings.h"
#include "swift/AST/DiagnosticsFrontend.h"
#include "swift/Basic/Platform.h"
#include "swift/Basic/SanitizerOptions.h"
#include "swift/Option/Options.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/Triple.h"
@@ -1224,6 +1225,10 @@ static bool ParseIRGenArgs(IRGenOptions &Opts, ArgList &Args,
}
}
if (const Arg *A = Args.getLastArg(options::OPT_sanitize_EQ)) {
Opts.Sanitize = parseSanitizerArgValues(A, &Diags);;
}
if (Args.hasArg(OPT_enable_reflection_metadata)) {
Opts.StripReflectionMetadata = false;
Opts.StripReflectionNames = false;