Skip to content

Commit 1f29622

Browse files
committed
Assertions: display the assertion help hint only once and after the assertion message
It's more readable if the first thing which is printed is the actual assertion message
1 parent 81005c1 commit 1f29622

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

lib/Basic/Assertions.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,6 @@ int CONDITIONAL_ASSERT_Global_enable_flag =
3737
#endif
3838

3939
void ASSERT_failure(const char *expr, const char *filename, int line, const char *func) {
40-
if (AssertHelp) {
41-
ASSERT_help();
42-
} else {
43-
llvm::errs() << "Assertion help: -Xllvm -assert-help\n";
44-
}
45-
46-
4740
// Format here matches that used by `assert` on macOS:
4841
llvm::errs()
4942
<< "Assertion failed: "
@@ -52,6 +45,8 @@ void ASSERT_failure(const char *expr, const char *filename, int line, const char
5245
<< filename << ":"
5346
<< line << ".\n";
5447

48+
ASSERT_help();
49+
5550
if (AssertContinue) {
5651
llvm::errs() << "Continuing after failed assertion (-Xllvm -assert-continue)\n";
5752
return;
@@ -67,6 +62,11 @@ void ASSERT_help() {
6762
}
6863
ASSERT_help_shown = 1;
6964

65+
if (!AssertHelp) {
66+
llvm::errs() << "(to display assertion configuration options: -Xllvm -assert-help)\n";
67+
return;
68+
}
69+
7070
llvm::errs() << "\n";
7171
llvm::errs() << "Control assertion behavior with one or more of the following options:\n\n";
7272
llvm::errs() << " -Xllvm -assert-continue\n";

0 commit comments

Comments
 (0)