Skip to content

Commit 7fbda77

Browse files
committed
Move OffloadError to shared
1 parent c0b8b68 commit 7fbda77

File tree

4 files changed

+20
-34
lines changed

4 files changed

+20
-34
lines changed

offload/plugins-nextgen/common/include/OffloadError.h renamed to offload/include/Shared/OffloadError.h

Lines changed: 8 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -14,32 +14,21 @@
1414
#include "llvm/Support/Error.h"
1515
#include "llvm/Support/ErrorHandling.h"
1616

17-
namespace llvm {
18-
namespace omp {
19-
namespace target {
20-
namespace plugin {
17+
namespace error {
2118

2219
enum class ErrorCode {
2320
#define OFFLOAD_ERRC(Name, _, Value) Name = Value,
2421
#include "Shared/OffloadErrcodes.inc"
2522
#undef OFFLOAD_ERRC
2623
};
2724

28-
} // namespace plugin
29-
} // namespace target
30-
} // namespace omp
31-
} // namespace llvm
25+
} // namespace error
3226

3327
namespace std {
34-
template <>
35-
struct is_error_code_enum<llvm::omp::target::plugin::ErrorCode>
36-
: std::true_type {};
28+
template <> struct is_error_code_enum<error::ErrorCode> : std::true_type {};
3729
} // namespace std
3830

39-
namespace llvm {
40-
namespace omp {
41-
namespace target {
42-
namespace plugin {
31+
namespace error {
4332

4433
const std::error_category &OffloadErrCategory();
4534

@@ -48,17 +37,15 @@ inline std::error_code make_error_code(ErrorCode E) {
4837
}
4938

5039
/// Base class for errors originating in DIA SDK, e.g. COM calls
51-
class OffloadError : public ErrorInfo<OffloadError, StringError> {
40+
class OffloadError : public llvm::ErrorInfo<OffloadError, llvm::StringError> {
5241
public:
5342
using ErrorInfo<OffloadError, StringError>::ErrorInfo;
5443

55-
OffloadError(const Twine &S) : ErrorInfo(S, ErrorCode::UNKNOWN) {}
44+
OffloadError(const llvm::Twine &S) : ErrorInfo(S, ErrorCode::UNKNOWN) {}
5645

46+
// The definition for this resides in the plugin static library
5747
static char ID;
5848
};
59-
} // namespace plugin
60-
} // namespace target
61-
} // namespace omp
62-
} // namespace llvm
49+
} // namespace error
6350

6451
#endif

offload/liboffload/include/OffloadImpl.hpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,8 @@ struct ol_impl_result_t {
105105

106106
private:
107107
static ol_errc_t GetErrorCode(std::error_code Code) {
108-
if (Code.category() == llvm::omp::target::plugin::make_error_code(
109-
llvm::omp::target::plugin::ErrorCode::SUCCESS)
110-
.category()) {
108+
if (Code.category() ==
109+
error::make_error_code(error::ErrorCode::SUCCESS).category()) {
111110
return static_cast<ol_errc_t>(Code.value());
112111
}
113112
return OL_ERRC_UNKNOWN;

offload/plugins-nextgen/common/include/PluginInterface.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,13 @@
2424
#include "Shared/Debug.h"
2525
#include "Shared/Environment.h"
2626
#include "Shared/EnvironmentVar.h"
27+
#include "Shared/OffloadError.h"
2728
#include "Shared/Requirements.h"
2829
#include "Shared/Utils.h"
2930

3031
#include "GlobalHandler.h"
3132
#include "JIT.h"
3233
#include "MemoryManager.h"
33-
#include "OffloadError.h"
3434
#include "RPC.h"
3535
#include "omptarget.h"
3636

@@ -1382,23 +1382,23 @@ static inline Error success() { return Error::success(); }
13821382

13831383
/// Create an Offload error.
13841384
template <typename... ArgsTy>
1385-
static Error error(ErrorCode Code, const char *ErrFmt, ArgsTy... Args) {
1385+
static Error error(error::ErrorCode Code, const char *ErrFmt, ArgsTy... Args) {
13861386
std::string Buffer;
13871387
raw_string_ostream(Buffer) << format(ErrFmt, Args...);
1388-
return make_error<OffloadError>(Code, Buffer);
1388+
return make_error<error::OffloadError>(Code, Buffer);
13891389
}
13901390

13911391
template <typename... ArgsTy>
13921392
static Error error(const char *ErrFmt, ArgsTy... Args) {
1393-
return error(ErrorCode::UNKNOWN, ErrFmt, Args...);
1393+
return error(error::ErrorCode::UNKNOWN, ErrFmt, Args...);
13941394
}
13951395

1396-
inline Error error(ErrorCode Code, const char *S) {
1397-
return make_error<OffloadError>(Code, S);
1396+
inline Error error(error::ErrorCode Code, const char *S) {
1397+
return make_error<error::OffloadError>(Code, S);
13981398
}
13991399

14001400
inline Error error(const char *S) {
1401-
return make_error<OffloadError>(ErrorCode::UNKNOWN, S);
1401+
return make_error<error::OffloadError>(error::ErrorCode::UNKNOWN, S);
14021402
}
14031403

14041404
/// Check the plugin-specific error code and return an error or success

offload/plugins-nextgen/common/src/OffloadError.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@
66
//
77
//===----------------------------------------------------------------------===//
88

9-
#include "OffloadError.h"
9+
#include "Shared/OffloadError.h"
1010
#include "llvm/Support/ErrorHandling.h"
1111

1212
using namespace llvm;
13-
using namespace llvm::omp::target::plugin;
13+
using namespace error;
1414

1515
namespace {
1616
// OffloadError inherits from llvm::StringError which requires a
@@ -32,7 +32,7 @@ class OffloadErrorCategory : public std::error_category {
3232
};
3333
} // namespace
3434

35-
const std::error_category &llvm::omp::target::plugin::OffloadErrCategory() {
35+
const std::error_category &error::OffloadErrCategory() {
3636
static OffloadErrorCategory MSFCategory;
3737
return MSFCategory;
3838
}

0 commit comments

Comments
 (0)