mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[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:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user