16b6b8c4fSAdrian McCarthy #include "llvm/DebugInfo/PDB/Native/RawError.h" 26b6b8c4fSAdrian McCarthy #include "llvm/Support/ErrorHandling.h" 36b6b8c4fSAdrian McCarthy 46b6b8c4fSAdrian McCarthy using namespace llvm; 56b6b8c4fSAdrian McCarthy using namespace llvm::pdb; 66b6b8c4fSAdrian McCarthy 7711950c1SBenjamin Kramer namespace { 86b6b8c4fSAdrian McCarthy // FIXME: This class is only here to support the transition to llvm::Error. It 96b6b8c4fSAdrian McCarthy // will be removed once this transition is complete. Clients should prefer to 106b6b8c4fSAdrian McCarthy // deal with the Error value directly, rather than converting to error_code. 116b6b8c4fSAdrian McCarthy class RawErrorCategory : public std::error_category { 126b6b8c4fSAdrian McCarthy public: name() const136b6b8c4fSAdrian McCarthy const char *name() const noexcept override { return "llvm.pdb.raw"; } message(int Condition) const146b6b8c4fSAdrian McCarthy std::string message(int Condition) const override { 156b6b8c4fSAdrian McCarthy switch (static_cast<raw_error_code>(Condition)) { 166b6b8c4fSAdrian McCarthy case raw_error_code::unspecified: 176b6b8c4fSAdrian McCarthy return "An unknown error has occurred."; 186b6b8c4fSAdrian McCarthy case raw_error_code::feature_unsupported: 196b6b8c4fSAdrian McCarthy return "The feature is unsupported by the implementation."; 206b6b8c4fSAdrian McCarthy case raw_error_code::invalid_format: 216b6b8c4fSAdrian McCarthy return "The record is in an unexpected format."; 226b6b8c4fSAdrian McCarthy case raw_error_code::corrupt_file: 236b6b8c4fSAdrian McCarthy return "The PDB file is corrupt."; 246b6b8c4fSAdrian McCarthy case raw_error_code::insufficient_buffer: 256b6b8c4fSAdrian McCarthy return "The buffer is not large enough to read the requested number of " 266b6b8c4fSAdrian McCarthy "bytes."; 276b6b8c4fSAdrian McCarthy case raw_error_code::no_stream: 286b6b8c4fSAdrian McCarthy return "The specified stream could not be loaded."; 296b6b8c4fSAdrian McCarthy case raw_error_code::index_out_of_bounds: 306b6b8c4fSAdrian McCarthy return "The specified item does not exist in the array."; 316b6b8c4fSAdrian McCarthy case raw_error_code::invalid_block_address: 326b6b8c4fSAdrian McCarthy return "The specified block address is not valid."; 336b6b8c4fSAdrian McCarthy case raw_error_code::duplicate_entry: 346b6b8c4fSAdrian McCarthy return "The entry already exists."; 356b6b8c4fSAdrian McCarthy case raw_error_code::no_entry: 366b6b8c4fSAdrian McCarthy return "The entry does not exist."; 376b6b8c4fSAdrian McCarthy case raw_error_code::not_writable: 386b6b8c4fSAdrian McCarthy return "The PDB does not support writing."; 39ea4e6075SZachary Turner case raw_error_code::stream_too_long: 40ea4e6075SZachary Turner return "The stream was longer than expected."; 416b6b8c4fSAdrian McCarthy case raw_error_code::invalid_tpi_hash: 426b6b8c4fSAdrian McCarthy return "The Type record has an invalid hash value."; 436b6b8c4fSAdrian McCarthy } 446b6b8c4fSAdrian McCarthy llvm_unreachable("Unrecognized raw_error_code"); 456b6b8c4fSAdrian McCarthy } 466b6b8c4fSAdrian McCarthy }; 47711950c1SBenjamin Kramer } // namespace 486b6b8c4fSAdrian McCarthy RawErrCategory()49*ede60037SNicolai Hähnleconst std::error_category &llvm::pdb::RawErrCategory() { 50*ede60037SNicolai Hähnle static RawErrorCategory RawCategory; 51*ede60037SNicolai Hähnle return RawCategory; 52*ede60037SNicolai Hähnle } 536b6b8c4fSAdrian McCarthy 546a7efef4SAlexandre Ganea char RawError::ID; 55