| 1 |
//===----------------------------------------------------------------------===// |
| 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 |
/// \file |
| 10 |
/// This file contains the implementation of the helper functions for the error |
| 11 |
/// handling macros. |
| 12 |
/// |
| 13 |
//===----------------------------------------------------------------------===// |
| 14 |
|
| 15 |
#include "mathtest/ErrorHandling.hpp" |
| 16 |
|
| 17 |
#include "llvm/ADT/Twine.h" |
| 18 |
#include "llvm/Support/ErrorHandling.h" |
| 19 |
|
| 20 |
#include <OffloadAPI.h> |
| 21 |
|
| 22 |
using namespace mathtest; |
| 23 |
|
| 24 |
[[noreturn]] void detail::reportFatalError(const llvm::Twine &Message, |
| 25 |
const char *File, int Line, |
| 26 |
const char *FuncName) { |
| 27 |
// clang-format off |
| 28 |
llvm::report_fatal_error( |
| 29 |
llvm::Twine("Fatal error in '") + FuncName + |
| 30 |
"' at " + File + ":" + llvm::Twine(Line) + |
| 31 |
"\n Message: " + Message, |
| 32 |
/*gen_crash_diag=*/false); |
| 33 |
// clang-format on |
| 34 |
} |
| 35 |
|
| 36 |
[[noreturn]] void detail::reportOffloadError(const char *ResultExpr, |
| 37 |
ol_result_t Result, |
| 38 |
const char *File, int Line, |
| 39 |
const char *FuncName) { |
| 40 |
// clang-format off |
| 41 |
llvm::report_fatal_error( |
| 42 |
llvm::Twine("OL_CHECK failed") + |
| 43 |
"\n Location: " + File + ":" + llvm::Twine(Line) + |
| 44 |
"\n Function: " + FuncName + |
| 45 |
"\n Expression: " + ResultExpr + |
| 46 |
"\n Error code: " + llvm::Twine(Result->Code) + |
| 47 |
"\n Details: " + |
| 48 |
(Result->Details ? Result->Details : "No details provided"), |
| 49 |
/*gen_crash_diag=*/false); |
| 50 |
// clang-format on |
| 51 |
} |