Fixing @llvm.memcpy not honoring volatile.
[llvm-core.git] / tools / obj2yaml / Error.h
blob315d7f4bf49f263daa5aa2eaab5e61314aa86408
1 //===- Error.h - system_error extensions for obj2yaml -----------*- C++ -*-===//
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 //===----------------------------------------------------------------------===//
9 #ifndef LLVM_TOOLS_OBJ2YAML_ERROR_H
10 #define LLVM_TOOLS_OBJ2YAML_ERROR_H
12 #include "llvm/Support/Error.h"
14 #include <system_error>
16 namespace llvm {
17 const std::error_category &obj2yaml_category();
19 enum class obj2yaml_error {
20 success = 0,
21 file_not_found,
22 unrecognized_file_format,
23 unsupported_obj_file_format,
24 not_implemented
27 inline std::error_code make_error_code(obj2yaml_error e) {
28 return std::error_code(static_cast<int>(e), obj2yaml_category());
31 class Obj2YamlError : public ErrorInfo<Obj2YamlError> {
32 public:
33 static char ID;
34 Obj2YamlError(obj2yaml_error C) : Code(C) {}
35 Obj2YamlError(std::string ErrMsg) : ErrMsg(std::move(ErrMsg)) {}
36 Obj2YamlError(obj2yaml_error C, std::string ErrMsg)
37 : ErrMsg(std::move(ErrMsg)), Code(C) {}
38 void log(raw_ostream &OS) const override;
39 const std::string &getErrorMessage() const { return ErrMsg; }
40 std::error_code convertToErrorCode() const override;
42 private:
43 std::string ErrMsg;
44 obj2yaml_error Code;
47 } // namespace llvm
49 namespace std {
50 template <> struct is_error_code_enum<llvm::obj2yaml_error> : std::true_type {};
53 #endif