]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/include/llvm/DebugInfo/PDB/Native/RawError.h
Merge llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and openmp
[FreeBSD/FreeBSD.git] / contrib / llvm / include / llvm / DebugInfo / PDB / Native / RawError.h
1 //===- RawError.h - Error extensions for raw PDB implementation -*- 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_RAW_RAWERROR_H
11 #define LLVM_DEBUGINFO_PDB_RAW_RAWERROR_H
12
13 #include "llvm/Support/Error.h"
14
15 #include <string>
16
17 namespace llvm {
18 namespace pdb {
19 enum class raw_error_code {
20   unspecified = 1,
21   feature_unsupported,
22   invalid_format,
23   corrupt_file,
24   insufficient_buffer,
25   no_stream,
26   index_out_of_bounds,
27   invalid_block_address,
28   duplicate_entry,
29   no_entry,
30   not_writable,
31   stream_too_long,
32   invalid_tpi_hash,
33 };
34 } // namespace pdb
35 } // namespace llvm
36
37 namespace std {
38 template <>
39 struct is_error_code_enum<llvm::pdb::raw_error_code> : std::true_type {};
40 } // namespace std
41
42 namespace llvm {
43 namespace pdb {
44 const std::error_category &RawErrCategory();
45
46 inline std::error_code make_error_code(raw_error_code E) {
47   return std::error_code(static_cast<int>(E), RawErrCategory());
48 }
49
50 /// Base class for errors originating when parsing raw PDB files
51 class RawError : public ErrorInfo<RawError, StringError> {
52 public:
53   using ErrorInfo<RawError, StringError>::ErrorInfo; // inherit constructors
54   RawError(const Twine &S) : ErrorInfo(S, raw_error_code::unspecified) {}
55   static char ID;
56 };
57 } // namespace pdb
58 } // namespace llvm
59 #endif