1
- // ===--- Assertions.cpp - Swift Version Number -------------------------------===//
1
+ // ===--- Assertions.cpp - Assertion macros - -------------------------------===//
2
2
//
3
3
// This source file is part of the Swift.org open source project
4
4
//
5
- // Copyright (c) 2023 - 2023 Apple Inc. and the Swift project authors
5
+ // Copyright (c) 2024 Apple Inc. and the Swift project authors
6
6
// Licensed under Apache License v2.0 with Runtime Library Exception
7
7
//
8
8
// See https://swift.org/LICENSE.txt for license information
9
9
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
10
10
//
11
11
// ===----------------------------------------------------------------------===//
12
12
//
13
- // This file defines custom assertion support functions
13
+ // This file defines implementation details of include/swift/Basic/Assertions.h.
14
14
//
15
15
// ===----------------------------------------------------------------------===//
16
16
17
17
#include " llvm/Support/CommandLine.h"
18
+ #include " llvm/Support/raw_ostream.h"
18
19
#include " swift/Basic/Assertions.h"
19
20
#undef NDEBUG
20
21
#include < cassert>
@@ -39,21 +40,20 @@ void ASSERT_failure(const char *expr, const char *filename, int line, const char
39
40
if (AssertHelp) {
40
41
ASSERT_help ();
41
42
} else {
42
- std::cerr << " Assertion help: -Xllvm -assert-help" << std::endl ;
43
+ llvm::errs () << " Assertion help: -Xllvm -assert-help\n " ;
43
44
}
44
45
45
46
46
47
// Format here matches that used by `assert` on macOS:
47
- std::cerr
48
+ llvm::errs ()
48
49
<< " Assertion failed: "
49
50
<< " (" << expr << " ), "
50
51
<< " function " << func << " at "
51
52
<< filename << " :"
52
- << line << " ."
53
- << std::endl;
53
+ << line << " .\n " ;
54
54
55
55
if (AssertContinue) {
56
- std::cerr << " Continuing after failed assertion (-Xllvm -assert-continue)" << std::endl ;
56
+ llvm::errs () << " Continuing after failed assertion (-Xllvm -assert-continue)\n " ;
57
57
return ;
58
58
}
59
59
@@ -67,12 +67,10 @@ void ASSERT_help() {
67
67
}
68
68
ASSERT_help_shown = 1 ;
69
69
70
- std::cerr << std::endl;
71
- std::cerr << " Control assertion behavior with one or more of the following options:" << std::endl;
72
- std::cerr << std::endl;
73
- std::cerr << " -Xllvm -assert-continue" << std::endl;
74
- std::cerr << " Continue after any failed assertion" << std::endl;
75
- std::cerr << std::endl;
70
+ llvm::errs () << " \n " ;
71
+ llvm::errs () << " Control assertion behavior with one or more of the following options:\n\n " ;
72
+ llvm::errs () << " -Xllvm -assert-continue\n " ;
73
+ llvm::errs () << " Continue after any failed assertion\n\n " ;
76
74
}
77
75
78
76
// This has to be callable in the same way as the macro version,
@@ -81,4 +79,3 @@ void ASSERT_help() {
81
79
int CONDITIONAL_ASSERT_enabled () {
82
80
return (CONDITIONAL_ASSERT_Global_enable_flag != 0 );
83
81
}
84
-
0 commit comments