DIAError.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. //===- DIAError.h - Error extensions for PDB DIA 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_DIA_DIAERROR_H
  14. #define LLVM_DEBUGINFO_PDB_DIA_DIAERROR_H
  15. #include "llvm/ADT/StringRef.h"
  16. #include "llvm/Support/Error.h"
  17. namespace llvm {
  18. namespace pdb {
  19. enum class dia_error_code {
  20. unspecified = 1,
  21. could_not_create_impl,
  22. invalid_file_format,
  23. invalid_parameter,
  24. already_loaded,
  25. debug_info_mismatch,
  26. };
  27. } // namespace pdb
  28. } // namespace llvm
  29. namespace std {
  30. template <>
  31. struct is_error_code_enum<llvm::pdb::dia_error_code> : std::true_type {};
  32. } // namespace std
  33. namespace llvm {
  34. namespace pdb {
  35. const std::error_category &DIAErrCategory();
  36. inline std::error_code make_error_code(dia_error_code E) {
  37. return std::error_code(static_cast<int>(E), DIAErrCategory());
  38. }
  39. /// Base class for errors originating in DIA SDK, e.g. COM calls
  40. class DIAError : public ErrorInfo<DIAError, StringError> {
  41. public:
  42. using ErrorInfo<DIAError, StringError>::ErrorInfo;
  43. DIAError(const Twine &S) : ErrorInfo(S, dia_error_code::unspecified) {}
  44. static char ID;
  45. };
  46. } // namespace pdb
  47. } // namespace llvm
  48. #endif
  49. #ifdef __GNUC__
  50. #pragma GCC diagnostic pop
  51. #endif