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