RawError.cpp 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. #include "llvm/DebugInfo/PDB/Native/RawError.h"
  2. #include "llvm/Support/ErrorHandling.h"
  3. #include "llvm/Support/ManagedStatic.h"
  4. using namespace llvm;
  5. using namespace llvm::pdb;
  6. namespace {
  7. // FIXME: This class is only here to support the transition to llvm::Error. It
  8. // will be removed once this transition is complete. Clients should prefer to
  9. // deal with the Error value directly, rather than converting to error_code.
  10. class RawErrorCategory : public std::error_category {
  11. public:
  12. const char *name() const noexcept override { return "llvm.pdb.raw"; }
  13. std::string message(int Condition) const override {
  14. switch (static_cast<raw_error_code>(Condition)) {
  15. case raw_error_code::unspecified:
  16. return "An unknown error has occurred.";
  17. case raw_error_code::feature_unsupported:
  18. return "The feature is unsupported by the implementation.";
  19. case raw_error_code::invalid_format:
  20. return "The record is in an unexpected format.";
  21. case raw_error_code::corrupt_file:
  22. return "The PDB file is corrupt.";
  23. case raw_error_code::insufficient_buffer:
  24. return "The buffer is not large enough to read the requested number of "
  25. "bytes.";
  26. case raw_error_code::no_stream:
  27. return "The specified stream could not be loaded.";
  28. case raw_error_code::index_out_of_bounds:
  29. return "The specified item does not exist in the array.";
  30. case raw_error_code::invalid_block_address:
  31. return "The specified block address is not valid.";
  32. case raw_error_code::duplicate_entry:
  33. return "The entry already exists.";
  34. case raw_error_code::no_entry:
  35. return "The entry does not exist.";
  36. case raw_error_code::not_writable:
  37. return "The PDB does not support writing.";
  38. case raw_error_code::stream_too_long:
  39. return "The stream was longer than expected.";
  40. case raw_error_code::invalid_tpi_hash:
  41. return "The Type record has an invalid hash value.";
  42. }
  43. llvm_unreachable("Unrecognized raw_error_code");
  44. }
  45. };
  46. } // namespace
  47. static llvm::ManagedStatic<RawErrorCategory> RawCategory;
  48. const std::error_category &llvm::pdb::RawErrCategory() { return *RawCategory; }
  49. char RawError::ID;