1//===- OffloadError.cpp - Error extensions for offload --------------------===//
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 "OffloadError.h"
10#include "llvm/Support/ErrorHandling.h"
11
12using namespace llvm;
13using namespace error;
14
15namespace {
16// OffloadError inherits from llvm::StringError which requires a
17// std::error_code. Once/if that requirement is removed, then this
18// std::error_code machinery can be removed.
19class OffloadErrorCategory : public std::error_category {
20public:
21 const char *name() const noexcept override { return "llvm.offload"; }
22 std::string message(int Condition) const override {
23 switch (static_cast<ErrorCode>(Condition)) {
24#define OFFLOAD_ERRC(Name, Desc, Value) \
25 case ErrorCode::Name: \
26 return #Desc;
27#include "OffloadErrcodes.inc"
28#undef OFFLOAD_ERRC
29 }
30 llvm_unreachable("Unrecognized offload ErrorCode");
31 }
32};
33} // namespace
34
35const std::error_category &error::OffloadErrCategory() {
36 static OffloadErrorCategory MSFCategory;
37 return MSFCategory;
38}
39
40char OffloadError::ID;
41

source code of offload/plugins-nextgen/common/src/OffloadError.cpp