MSFError.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. #pragma once
  2. #ifdef __GNUC__
  3. #pragma GCC diagnostic push
  4. #pragma GCC diagnostic ignored "-Wunused-parameter"
  5. #endif
  6. //===- MSFError.h - Error extensions for MSF Files --------------*- 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_MSF_MSFERROR_H
  14. #define LLVM_DEBUGINFO_MSF_MSFERROR_H
  15. #include "llvm/Support/Error.h"
  16. namespace llvm {
  17. namespace msf {
  18. enum class msf_error_code {
  19. unspecified = 1,
  20. insufficient_buffer,
  21. size_overflow_4096,
  22. size_overflow_8192,
  23. size_overflow_16384,
  24. size_overflow_32768,
  25. not_writable,
  26. no_stream,
  27. invalid_format,
  28. block_in_use
  29. };
  30. } // namespace msf
  31. } // namespace llvm
  32. namespace std {
  33. template <>
  34. struct is_error_code_enum<llvm::msf::msf_error_code> : std::true_type {};
  35. } // namespace std
  36. namespace llvm {
  37. namespace msf {
  38. const std::error_category &MSFErrCategory();
  39. inline std::error_code make_error_code(msf_error_code E) {
  40. return std::error_code(static_cast<int>(E), MSFErrCategory());
  41. }
  42. /// Base class for errors originating when parsing raw PDB files
  43. class MSFError : public ErrorInfo<MSFError, StringError> {
  44. public:
  45. using ErrorInfo<MSFError, StringError>::ErrorInfo; // inherit constructors
  46. MSFError(const Twine &S) : ErrorInfo(S, msf_error_code::unspecified) {}
  47. static char ID;
  48. };
  49. } // namespace msf
  50. } // namespace llvm
  51. #endif // LLVM_DEBUGINFO_MSF_MSFERROR_H
  52. #ifdef __GNUC__
  53. #pragma GCC diagnostic pop
  54. #endif