CodeViewError.cpp 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. //===- CodeViewError.cpp - 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. #include "llvm/DebugInfo/CodeView/CodeViewError.h"
  9. #include "llvm/Support/ErrorHandling.h"
  10. #include <string>
  11. using namespace llvm;
  12. using namespace llvm::codeview;
  13. namespace {
  14. // FIXME: This class is only here to support the transition to llvm::Error. It
  15. // will be removed once this transition is complete. Clients should prefer to
  16. // deal with the Error value directly, rather than converting to error_code.
  17. class CodeViewErrorCategory : public std::error_category {
  18. public:
  19. const char *name() const noexcept override { return "llvm.codeview"; }
  20. std::string message(int Condition) const override {
  21. switch (static_cast<cv_error_code>(Condition)) {
  22. case cv_error_code::unspecified:
  23. return "An unknown CodeView error has occurred.";
  24. case cv_error_code::insufficient_buffer:
  25. return "The buffer is not large enough to read the requested number of "
  26. "bytes.";
  27. case cv_error_code::corrupt_record:
  28. return "The CodeView record is corrupted.";
  29. case cv_error_code::no_records:
  30. return "There are no records.";
  31. case cv_error_code::operation_unsupported:
  32. return "The requested operation is not supported.";
  33. case cv_error_code::unknown_member_record:
  34. return "The member record is of an unknown type.";
  35. }
  36. llvm_unreachable("Unrecognized cv_error_code");
  37. }
  38. };
  39. } // namespace
  40. const std::error_category &llvm::codeview::CVErrorCategory() {
  41. static CodeViewErrorCategory CodeViewErrCategory;
  42. return CodeViewErrCategory;
  43. }
  44. char CodeViewError::ID;