RawError.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. #pragma once
  2. #ifdef __GNUC__
  3. #pragma GCC diagnostic push
  4. #pragma GCC diagnostic ignored "-Wunused-parameter"
  5. #endif
  6. //===- RawError.h - Error extensions for raw PDB implementation -*- 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_NATIVE_RAWERROR_H
  14. #define LLVM_DEBUGINFO_PDB_NATIVE_RAWERROR_H
  15. #include "llvm/Support/Error.h"
  16. namespace llvm {
  17. namespace pdb {
  18. enum class raw_error_code {
  19. unspecified = 1,
  20. feature_unsupported,
  21. invalid_format,
  22. corrupt_file,
  23. insufficient_buffer,
  24. no_stream,
  25. index_out_of_bounds,
  26. invalid_block_address,
  27. duplicate_entry,
  28. no_entry,
  29. not_writable,
  30. stream_too_long,
  31. invalid_tpi_hash,
  32. };
  33. } // namespace pdb
  34. } // namespace llvm
  35. namespace std {
  36. template <>
  37. struct is_error_code_enum<llvm::pdb::raw_error_code> : std::true_type {};
  38. } // namespace std
  39. namespace llvm {
  40. namespace pdb {
  41. const std::error_category &RawErrCategory();
  42. inline std::error_code make_error_code(raw_error_code E) {
  43. return std::error_code(static_cast<int>(E), RawErrCategory());
  44. }
  45. /// Base class for errors originating when parsing raw PDB files
  46. class RawError : public ErrorInfo<RawError, StringError> {
  47. public:
  48. using ErrorInfo<RawError, StringError>::ErrorInfo; // inherit constructors
  49. RawError(const Twine &S) : ErrorInfo(S, raw_error_code::unspecified) {}
  50. static char ID;
  51. };
  52. } // namespace pdb
  53. } // namespace llvm
  54. #endif
  55. #ifdef __GNUC__
  56. #pragma GCC diagnostic pop
  57. #endif