Home | History | Annotate | Line # | Download | only in PDB
      1 //===- GenericError.h - system_error extensions for PDB ---------*- 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_GENERICERROR_H
     10 #define LLVM_DEBUGINFO_PDB_GENERICERROR_H
     11 
     12 #include "llvm/Support/Error.h"
     13 
     14 namespace llvm {
     15 namespace pdb {
     16 
     17 enum class pdb_error_code {
     18   invalid_utf8_path = 1,
     19   dia_sdk_not_present,
     20   dia_failed_loading,
     21   signature_out_of_date,
     22   no_matching_pch,
     23   unspecified,
     24 };
     25 } // namespace pdb
     26 } // namespace llvm
     27 
     28 namespace std {
     29 template <>
     30 struct is_error_code_enum<llvm::pdb::pdb_error_code> : std::true_type {};
     31 } // namespace std
     32 
     33 namespace llvm {
     34 namespace pdb {
     35 const std::error_category &PDBErrCategory();
     36 
     37 inline std::error_code make_error_code(pdb_error_code E) {
     38   return std::error_code(static_cast<int>(E), PDBErrCategory());
     39 }
     40 
     41 /// Base class for errors originating when parsing raw PDB files
     42 class PDBError : public ErrorInfo<PDBError, StringError> {
     43 public:
     44   using ErrorInfo<PDBError, StringError>::ErrorInfo; // inherit constructors
     45   PDBError(const Twine &S) : ErrorInfo(S, pdb_error_code::unspecified) {}
     46   static char ID;
     47 };
     48 } // namespace pdb
     49 } // namespace llvm
     50 #endif
     51