Skip to content

Driver: Parse sanitizer=... as a SIL argument. #7921

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 6, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions include/swift/AST/SILOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#ifndef SWIFT_AST_SILOPTIONS_H
#define SWIFT_AST_SILOPTIONS_H

#include "swift/Basic/Sanitizers.h"
#include "llvm/ADT/StringRef.h"
#include <string>
#include <climits>
Expand Down Expand Up @@ -122,6 +123,12 @@ class SILOptions {

/// Assume that code will be executed in a single-threaded environment.
bool AssumeSingleThreaded = false;

/// Indicates which sanitizer is turned on.
SanitizerKind Sanitize : 2;

SILOptions() : Sanitize(SanitizerKind::None) {}

};

} // end namespace swift
Expand Down
16 changes: 10 additions & 6 deletions lib/Frontend/CompilerInvocation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1114,7 +1114,8 @@ static void PrintArg(raw_ostream &OS, const char *Arg, bool Quote) {
static bool ParseSILArgs(SILOptions &Opts, ArgList &Args,
IRGenOptions &IRGenOpts,
FrontendOptions &FEOpts,
DiagnosticEngine &Diags) {
DiagnosticEngine &Diags,
const llvm::Triple &Triple) {
using namespace options;

if (const Arg *A = Args.getLastArg(OPT_sil_inline_threshold)) {
Expand Down Expand Up @@ -1228,6 +1229,12 @@ static bool ParseSILArgs(SILOptions &Opts, ArgList &Args,
BaseName = FEOpts.ModuleName;
Opts.SILOutputFileNameForDebugging = BaseName.str();
}

if (const Arg *A = Args.getLastArg(options::OPT_sanitize_EQ)) {
Opts.Sanitize = parseSanitizerArgValues(A, Triple, Diags);
IRGenOpts.Sanitize = Opts.Sanitize;
}

return false;
}

Expand Down Expand Up @@ -1403,10 +1410,6 @@ static bool ParseIRGenArgs(IRGenOptions &Opts, ArgList &Args,
}
}

if (const Arg *A = Args.getLastArg(options::OPT_sanitize_EQ)) {
Opts.Sanitize = parseSanitizerArgValues(A, Triple, Diags);
}

if (const Arg *A = Args.getLastArg(options::OPT_sanitize_coverage_EQ)) {
Opts.SanitizeCoverage =
parseSanitizerCoverageArgValue(A, Triple, Diags, Opts.Sanitize);
Expand Down Expand Up @@ -1474,7 +1477,8 @@ bool CompilerInvocation::parseArgs(ArrayRef<const char *> Args,
return true;
}

if (ParseSILArgs(SILOpts, ParsedArgs, IRGenOpts, FrontendOpts, Diags)) {
if (ParseSILArgs(SILOpts, ParsedArgs, IRGenOpts, FrontendOpts, Diags,
LangOpts.Target)) {
return true;
}

Expand Down