[frontend] Added a handful of options to force the frontend to assert or crash.

Added -debug-assert-immediately and -debug-crash-immediately, which cause an
llvm_unreachable or LLVM_BUILTIN_TRAP to execute during argument parsing.

Added -debug-assert-after-parse and -debug-crash-after-parse, which cause an
llvm_unreachable or LLVM_BUILTIN_TRAP to execute after calling
CompilerInstance::performParse().

This fixes <rdar://problem/16013025>.

Swift SVN r13653
This commit is contained in:
Connor Wakamo
2014-02-07 22:03:32 +00:00
parent c9f7bba46d
commit 9747d87ff6
4 changed files with 47 additions and 0 deletions

View File

@@ -65,6 +65,23 @@ static bool ParseFrontendArgs(FrontendOptions &Opts, ArgList &Args,
DiagnosticEngine &Diags) {
using namespace options;
if (const Arg *A = Args.getLastArg(OPT_debug_crash_Group)) {
Option Opt = A->getOption();
if (Opt.matches(OPT_debug_assert_immediately)) {
llvm_unreachable("This is an assertion!");
} else if (Opt.matches(OPT_debug_crash_immediately)) {
LLVM_BUILTIN_TRAP;
} else if (Opt.matches(OPT_debug_assert_after_parse)) {
// Set in FrontendOptions
Opts.CrashMode = FrontendOptions::DebugCrashMode::AssertAfterParse;
} else if (Opt.matches(OPT_debug_crash_after_parse)) {
// Set in FrontendOptions
Opts.CrashMode = FrontendOptions::DebugCrashMode::CrashAfterParse;
} else {
llvm_unreachable("Unknown debug_crash_Group option!");
}
}
if (Args.hasArg(OPT_emit_verbose_sil)) {
Opts.EmitVerboseSIL = true;
}