1 //===- MSFError.h - Error extensions for MSF Files --------------*- 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_MSF_MSFERROR_H
10 #define LLVM_DEBUGINFO_MSF_MSFERROR_H
11 
12 #include "llvm/Support/Error.h"
13 
14 namespace llvm {
15 namespace msf {
16 enum class msf_error_code {
17   unspecified = 1,
18   insufficient_buffer,
19   size_overflow_4096,
20   size_overflow_8192,
21   size_overflow_16384,
22   size_overflow_32768,
23   not_writable,
24   no_stream,
25   invalid_format,
26   block_in_use
27 };
28 } // namespace msf
29 } // namespace llvm
30 
31 namespace std {
32 template <>
33 struct is_error_code_enum<llvm::msf::msf_error_code> : std::true_type {};
34 } // namespace std
35 
36 namespace llvm {
37 namespace msf {
38 const std::error_category &MSFErrCategory();
39 
40 inline std::error_code make_error_code(msf_error_code E) {
41   return std::error_code(static_cast<int>(E), MSFErrCategory());
42 }
43 
44 /// Base class for errors originating when parsing raw PDB files
45 class MSFError : public ErrorInfo<MSFError, StringError> {
46 public:
47   using ErrorInfo<MSFError, StringError>::ErrorInfo; // inherit constructors
48   MSFError(const Twine &S) : ErrorInfo(S, msf_error_code::unspecified) {}
49   static char ID;
50 };
51 } // namespace msf
52 } // namespace llvm
53 
54 #endif // LLVM_DEBUGINFO_MSF_MSFERROR_H
55