CodeViewError.h 1.5 KB

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