Skip to content

Commit 9264125

Browse files
committed
[Basic] NFC: Remove ASSERT_help from header
It's not clear this is a useful utility to expose since it will only print the message once.
1 parent d46aec9 commit 9264125

File tree

2 files changed

+18
-25
lines changed

2 files changed

+18
-25
lines changed

include/swift/Basic/Assertions.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -190,11 +190,4 @@ extern int CONDITIONAL_ASSERT_Global_enable_flag;
190190
#define SWIFT_ASSERT_ONLY_DECL DEBUG_ASSERT_DECL
191191
#define SWIFT_ASSERT_ONLY DEBUG_ASSERT_EXPR
192192

193-
// ================================ Utility and Helper Functions ================================
194-
195-
// Utility function to print out help information for
196-
// various command-line options that affect the assertion
197-
// behavior.
198-
void ASSERT_help();
199-
200193
#endif // SWIFT_BASIC_ASSERTIONS_H

lib/Basic/Assertions.cpp

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,24 @@ int CONDITIONAL_ASSERT_Global_enable_flag =
3434
1; // Default to `on` in debug builds
3535
#endif
3636

37+
static void ASSERT_help() {
38+
static int ASSERT_help_shown = 0;
39+
if (ASSERT_help_shown) {
40+
return;
41+
}
42+
ASSERT_help_shown = 1;
43+
44+
if (!AssertHelp) {
45+
llvm::errs() << "(to display assertion configuration options: -Xllvm -assert-help)\n";
46+
return;
47+
}
48+
49+
llvm::errs() << "\n";
50+
llvm::errs() << "Control assertion behavior with one or more of the following options:\n\n";
51+
llvm::errs() << " -Xllvm -assert-continue\n";
52+
llvm::errs() << " Continue after any failed assertion\n\n";
53+
}
54+
3755
void ASSERT_failure(const char *expr, const char *filename, int line, const char *func) {
3856
// Find the last component of `filename`
3957
// Needed on Windows MSVC, which lacks __FILE_NAME__
@@ -62,24 +80,6 @@ void ASSERT_failure(const char *expr, const char *filename, int line, const char
6280
abort();
6381
}
6482

65-
void ASSERT_help() {
66-
static int ASSERT_help_shown = 0;
67-
if (ASSERT_help_shown) {
68-
return;
69-
}
70-
ASSERT_help_shown = 1;
71-
72-
if (!AssertHelp) {
73-
llvm::errs() << "(to display assertion configuration options: -Xllvm -assert-help)\n";
74-
return;
75-
}
76-
77-
llvm::errs() << "\n";
78-
llvm::errs() << "Control assertion behavior with one or more of the following options:\n\n";
79-
llvm::errs() << " -Xllvm -assert-continue\n";
80-
llvm::errs() << " Continue after any failed assertion\n\n";
81-
}
82-
8383
// This has to be callable in the same way as the macro version,
8484
// so we can't put it inside a namespace.
8585
#undef CONDITIONAL_ASSERT_enabled

0 commit comments

Comments
 (0)