Handle debug-crash options in separate functions.

...so they show up in stack traces.

Swift SVN r31592
This commit is contained in:
Jordan Rose
2015-09-01 00:22:29 +00:00
parent e273ae1e9e
commit 6e8140b871
2 changed files with 32 additions and 8 deletions

View File

@@ -76,6 +76,20 @@ SourceFileKind CompilerInvocation::getSourceFileKind() const {
}
}
// This is a separate function so that it shows up in stack traces.
LLVM_ATTRIBUTE_NOINLINE
static void debugFailWithAssertion() {
// This assertion should always fail, per the user's request, and should
// not be converted to llvm_unreachable.
assert(0 && "This is an assertion!");
}
// This is a separate function so that it shows up in stack traces.
LLVM_ATTRIBUTE_NOINLINE
static void debugFailWithCrash() {
LLVM_BUILTIN_TRAP;
}
static bool ParseFrontendArgs(FrontendOptions &Opts, ArgList &Args,
DiagnosticEngine &Diags) {
using namespace options;
@@ -83,11 +97,9 @@ static bool ParseFrontendArgs(FrontendOptions &Opts, ArgList &Args,
if (const Arg *A = Args.getLastArg(OPT_debug_crash_Group)) {
Option Opt = A->getOption();
if (Opt.matches(OPT_debug_assert_immediately)) {
// This assertion should always fail, per the user's request, and should
// not be converted to llvm_unreachable.
assert(0 && "This is an assertion!");
debugFailWithAssertion();
} else if (Opt.matches(OPT_debug_crash_immediately)) {
LLVM_BUILTIN_TRAP;
debugFailWithCrash();
} else if (Opt.matches(OPT_debug_assert_after_parse)) {
// Set in FrontendOptions
Opts.CrashMode = FrontendOptions::DebugCrashMode::AssertAfterParse;