Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 1 | //===- Error.h - system_error extensions for PDB ----------------*- 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_ERROR_H |
| 11 | #define LLVM_DEBUGINFO_PDB_ERROR_H |
| 12 | |
| 13 | #include "llvm/ADT/StringRef.h" |
| 14 | #include "llvm/Support/Error.h" |
| 15 | |
| 16 | namespace llvm { |
| 17 | namespace pdb { |
| 18 | |
Andrew Scull | 0372a57 | 2018-11-16 15:47:06 +0000 | [diff] [blame] | 19 | enum class pdb_error_code { |
| 20 | invalid_utf8_path = 1, |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 21 | dia_sdk_not_present, |
Andrew Scull | 0372a57 | 2018-11-16 15:47:06 +0000 | [diff] [blame] | 22 | dia_failed_loading, |
| 23 | signature_out_of_date, |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 24 | type_server_not_found, |
| 25 | unspecified, |
| 26 | }; |
Andrew Scull | 0372a57 | 2018-11-16 15:47:06 +0000 | [diff] [blame] | 27 | } // namespace codeview |
| 28 | } // namespace llvm |
| 29 | |
| 30 | namespace std { |
| 31 | template <> |
| 32 | struct is_error_code_enum<llvm::pdb::pdb_error_code> : std::true_type {}; |
| 33 | } // namespace std |
| 34 | |
| 35 | namespace llvm { |
| 36 | namespace pdb { |
| 37 | const std::error_category &PDBErrCategory(); |
| 38 | |
| 39 | inline std::error_code make_error_code(pdb_error_code E) { |
| 40 | return std::error_code(static_cast<int>(E), PDBErrCategory()); |
| 41 | } |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 42 | |
| 43 | /// Base class for errors originating when parsing raw PDB files |
Andrew Scull | 0372a57 | 2018-11-16 15:47:06 +0000 | [diff] [blame] | 44 | class PDBError : public ErrorInfo<PDBError, StringError> { |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 45 | public: |
Andrew Scull | 0372a57 | 2018-11-16 15:47:06 +0000 | [diff] [blame] | 46 | using ErrorInfo<PDBError, StringError>::ErrorInfo; // inherit constructors |
| 47 | PDBError(const Twine &S) : ErrorInfo(S, pdb_error_code::unspecified) {} |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 48 | static char ID; |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 49 | }; |
Andrew Scull | 0372a57 | 2018-11-16 15:47:06 +0000 | [diff] [blame] | 50 | } // namespace pdb |
| 51 | } // namespace llvm |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 52 | #endif |