1 //===- CodeViewError.h - Error extensions for CodeView ----------*- 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_CODEVIEW_CODEVIEWERROR_H 10 #define LLVM_DEBUGINFO_CODEVIEW_CODEVIEWERROR_H 11 12 #include "llvm/Support/Compiler.h" 13 #include "llvm/Support/Error.h" 14 15 namespace llvm { 16 namespace codeview { 17 enum class cv_error_code { 18 unspecified = 1, 19 insufficient_buffer, 20 operation_unsupported, 21 corrupt_record, 22 no_records, 23 unknown_member_record, 24 }; 25 } // namespace codeview 26 } // namespace llvm 27 28 namespace std { 29 template <> 30 struct is_error_code_enum<llvm::codeview::cv_error_code> : std::true_type {}; 31 } // namespace std 32 33 namespace llvm { 34 namespace codeview { 35 LLVM_ABI const std::error_category &CVErrorCategory(); 36 37 inline std::error_code make_error_code(cv_error_code E) { 38 return std::error_code(static_cast<int>(E), CVErrorCategory()); 39 } 40 41 /// Base class for errors originating when parsing raw PDB files 42 class CodeViewError : public ErrorInfo<CodeViewError, StringError> { 43 public: 44 using ErrorInfo<CodeViewError, 45 StringError>::ErrorInfo; // inherit constructors 46 CodeViewError(const Twine &S) : ErrorInfo(S, cv_error_code::unspecified) {} 47 LLVM_ABI static char ID; 48 }; 49 50 } // namespace codeview 51 } // namespace llvm 52 53 #endif 54