GenericError.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. #pragma once
  2. #ifdef __GNUC__
  3. #pragma GCC diagnostic push
  4. #pragma GCC diagnostic ignored "-Wunused-parameter"
  5. #endif
  6. //===- GenericError.h - system_error extensions for PDB ---------*- C++ -*-===//
  7. //
  8. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  9. // See https://llvm.org/LICENSE.txt for license information.
  10. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  11. //
  12. //===----------------------------------------------------------------------===//
  13. #ifndef LLVM_DEBUGINFO_PDB_GENERICERROR_H
  14. #define LLVM_DEBUGINFO_PDB_GENERICERROR_H
  15. #include "llvm/Support/Error.h"
  16. namespace llvm {
  17. namespace pdb {
  18. enum class pdb_error_code {
  19. invalid_utf8_path = 1,
  20. dia_sdk_not_present,
  21. dia_failed_loading,
  22. signature_out_of_date,
  23. no_matching_pch,
  24. unspecified,
  25. };
  26. } // namespace pdb
  27. } // namespace llvm
  28. namespace std {
  29. template <>
  30. struct is_error_code_enum<llvm::pdb::pdb_error_code> : std::true_type {};
  31. } // namespace std
  32. namespace llvm {
  33. namespace pdb {
  34. const std::error_category &PDBErrCategory();
  35. inline std::error_code make_error_code(pdb_error_code E) {
  36. return std::error_code(static_cast<int>(E), PDBErrCategory());
  37. }
  38. /// Base class for errors originating when parsing raw PDB files
  39. class PDBError : public ErrorInfo<PDBError, StringError> {
  40. public:
  41. using ErrorInfo<PDBError, StringError>::ErrorInfo; // inherit constructors
  42. PDBError(const Twine &S) : ErrorInfo(S, pdb_error_code::unspecified) {}
  43. static char ID;
  44. };
  45. } // namespace pdb
  46. } // namespace llvm
  47. #endif
  48. #ifdef __GNUC__
  49. #pragma GCC diagnostic pop
  50. #endif