1 //===-- Implementation of __assert_fail -----------------------------------===// 2 // 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 // See https://llvm.org/LICENSE.txt for license information. 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 // 7 //===----------------------------------------------------------------------===// 8 9 #include "src/__support/OSUtil/io.h" 10 #include "src/assert/__assert_fail.h" 11 #include "src/stdlib/abort.h" 12 13 namespace __llvm_libc { 14 15 LLVM_LIBC_FUNCTION(void, __assert_fail, 16 (const char *assertion, const char *file, unsigned line, 17 const char *function)) { 18 write_to_stderr(file); 19 write_to_stderr(": Assertion failed: '"); 20 write_to_stderr(assertion); 21 write_to_stderr("' in function: '"); 22 write_to_stderr(function); 23 write_to_stderr("'\n"); 24 __llvm_libc::abort(); 25 } 26 27 } // namespace __llvm_libc 28