mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Handle debug-crash options in separate functions.
...so they show up in stack traces. Swift SVN r31592
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user