1 | //===- CodeViewError.h - Error extensions for CodeView ----------*- 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 | //===----------------------------------------------------------------------===// |
8 | |
9 | #ifndef LLVM_DEBUGINFO_CODEVIEW_CODEVIEWERROR_H |
10 | #define LLVM_DEBUGINFO_CODEVIEW_CODEVIEWERROR_H |
11 | |
12 | #include "llvm/Support/Error.h" |
13 | |
14 | namespace llvm { |
15 | namespace codeview { |
16 | enum class cv_error_code { |
17 | unspecified = 1, |
18 | insufficient_buffer, |
19 | operation_unsupported, |
20 | corrupt_record, |
21 | no_records, |
22 | unknown_member_record, |
23 | }; |
24 | } // namespace codeview |
25 | } // namespace llvm |
26 | |
27 | namespace std { |
28 | template <> |
29 | struct is_error_code_enum<llvm::codeview::cv_error_code> : std::true_type {}; |
30 | } // namespace std |
31 | |
32 | namespace llvm { |
33 | namespace codeview { |
34 | const std::error_category &CVErrorCategory(); |
35 | |
36 | inline std::error_code make_error_code(cv_error_code E) { |
37 | return std::error_code(static_cast<int>(E), CVErrorCategory()); |
38 | } |
39 | |
40 | /// Base class for errors originating when parsing raw PDB files |
41 | class CodeViewError : public ErrorInfo<CodeViewError, StringError> { |
42 | public: |
43 | using ErrorInfo<CodeViewError, |
44 | StringError>::ErrorInfo; // inherit constructors |
45 | CodeViewError(const Twine &S) : ErrorInfo(S, cv_error_code::unspecified) {} |
46 | static char ID; |
47 | }; |
48 | |
49 | } // namespace codeview |
50 | } // namespace llvm |
51 | |
52 | #endif |
53 | |