CodeViewError.cpp 1.9 KB

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