Files
clang-p2996/offload/plugins-nextgen/common/src/OffloadError.cpp
Callum Fare b78bc35d16 [Offload] Don't check in generated files (#141982)
Previously we decided to check in files that we generate with tablegen.
The justification at the time was that it helped reviewers unfamiliar
with `offload-tblgen` see the actual changes to the headers in PRs.
After trying it for a while, it's ended up causing some headaches and is
also not how tablegen is used elsewhere in LLVM.

This changes our use of tablegen to be more conventional. Where
possible, files are still clang-formatted, but this is no longer a hard
requirement. Because `OffloadErrcodes.inc` is shared with libomptarget
it now gets generated in a more appropriate place.
2025-06-03 10:39:04 -05:00

41 lines
1.3 KiB
C++

//===- OffloadError.cpp - Error extensions for offload --------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include "OffloadError.h"
#include "llvm/Support/ErrorHandling.h"
using namespace llvm;
using namespace error;
namespace {
// OffloadError inherits from llvm::StringError which requires a
// std::error_code. Once/if that requirement is removed, then this
// std::error_code machinery can be removed.
class OffloadErrorCategory : public std::error_category {
public:
const char *name() const noexcept override { return "llvm.offload"; }
std::string message(int Condition) const override {
switch (static_cast<ErrorCode>(Condition)) {
#define OFFLOAD_ERRC(Name, Desc, Value) \
case ErrorCode::Name: \
return #Desc;
#include "OffloadErrcodes.inc"
#undef OFFLOAD_ERRC
}
llvm_unreachable("Unrecognized offload ErrorCode");
}
};
} // namespace
const std::error_category &error::OffloadErrCategory() {
static OffloadErrorCategory MSFCategory;
return MSFCategory;
}
char OffloadError::ID;