1 //===- CodeViewError.h - Error extensions for CodeView ----------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 
10 #ifndef LLVM_DEBUGINFO_PDB_CODEVIEW_CODEVIEWERROR_H
11 #define LLVM_DEBUGINFO_PDB_CODEVIEW_CODEVIEWERROR_H
12 
13 #include "llvm/Support/Error.h"
14 
15 #include <string>
16 
17 namespace llvm {
18 namespace codeview {
19 enum class cv_error_code {
20   unspecified = 1,
21   insufficient_buffer,
22   operation_unsupported,
23   corrupt_record,
24   no_records,
25   unknown_member_record,
26 };
27 } // namespace codeview
28 } // namespace llvm
29 
30 namespace std {
31 template <>
32 struct is_error_code_enum<llvm::codeview::cv_error_code> : std::true_type {};
33 } // namespace std
34 
35 namespace llvm {
36 namespace codeview {
37 const std::error_category &CVErrorCategory();
38 
39 inline std::error_code make_error_code(cv_error_code E) {
40   return std::error_code(static_cast<int>(E), CVErrorCategory());
41 }
42 
43 /// Base class for errors originating when parsing raw PDB files
44 class CodeViewError : public ErrorInfo<CodeViewError, StringError> {
45 public:
46   using ErrorInfo<CodeViewError,
47                   StringError>::ErrorInfo; // inherit constructors
48   CodeViewError(const Twine &S) : ErrorInfo(S, cv_error_code::unspecified) {}
49   static char ID;
50 };
51 
52 } // namespace codeview
53 } // namespace llvm
54 
55 #endif
56