1- // ===--- Assertions.cpp - Swift Version Number -------------------------------===//
1+ // ===--- Assertions.cpp - Assertion macros - -------------------------------===//
22//
33// This source file is part of the Swift.org open source project
44//
5- // Copyright (c) 2023 - 2023 Apple Inc. and the Swift project authors
5+ // Copyright (c) 2024 Apple Inc. and the Swift project authors
66// Licensed under Apache License v2.0 with Runtime Library Exception
77//
88// See https://swift.org/LICENSE.txt for license information
99// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
1010//
1111// ===----------------------------------------------------------------------===//
1212//
13- // This file defines custom assertion support functions
13+ // This file defines implementation details of include/swift/Basic/Assertions.h.
1414//
1515// ===----------------------------------------------------------------------===//
1616
1717#include " llvm/Support/CommandLine.h"
18+ #include " llvm/Support/raw_ostream.h"
1819#include " swift/Basic/Assertions.h"
1920#undef NDEBUG
2021#include < cassert>
@@ -39,21 +40,20 @@ void ASSERT_failure(const char *expr, const char *filename, int line, const char
3940 if (AssertHelp) {
4041 ASSERT_help ();
4142 } else {
42- std::cerr << " Assertion help: -Xllvm -assert-help" << std::endl ;
43+ llvm::errs () << " Assertion help: -Xllvm -assert-help\n " ;
4344 }
4445
4546
4647 // Format here matches that used by `assert` on macOS:
47- std::cerr
48+ llvm::errs ()
4849 << " Assertion failed: "
4950 << " (" << expr << " ), "
5051 << " function " << func << " at "
5152 << filename << " :"
52- << line << " ."
53- << std::endl;
53+ << line << " .\n " ;
5454
5555 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 " ;
5757 return ;
5858 }
5959
@@ -67,12 +67,10 @@ void ASSERT_help() {
6767 }
6868 ASSERT_help_shown = 1 ;
6969
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 " ;
7674}
7775
7876// This has to be callable in the same way as the macro version,
@@ -81,4 +79,3 @@ void ASSERT_help() {
8179int CONDITIONAL_ASSERT_enabled () {
8280 return (CONDITIONAL_ASSERT_Global_enable_flag != 0 );
8381}
84-
0 commit comments