13ca95b02SDimitry Andric //===- CodeViewError.cpp - Error extensions for CodeView --------*- C++ -*-===// 23ca95b02SDimitry Andric // 33ca95b02SDimitry Andric // The LLVM Compiler Infrastructure 43ca95b02SDimitry Andric // 53ca95b02SDimitry Andric // This file is distributed under the University of Illinois Open Source 63ca95b02SDimitry Andric // License. See LICENSE.TXT for details. 73ca95b02SDimitry Andric // 83ca95b02SDimitry Andric //===----------------------------------------------------------------------===// 93ca95b02SDimitry Andric 103ca95b02SDimitry Andric #include "llvm/DebugInfo/CodeView/CodeViewError.h" 113ca95b02SDimitry Andric #include "llvm/Support/ErrorHandling.h" 123ca95b02SDimitry Andric #include "llvm/Support/ManagedStatic.h" 133ca95b02SDimitry Andric 143ca95b02SDimitry Andric using namespace llvm; 153ca95b02SDimitry Andric using namespace llvm::codeview; 163ca95b02SDimitry Andric 173ca95b02SDimitry Andric // FIXME: This class is only here to support the transition to llvm::Error. It 183ca95b02SDimitry Andric // will be removed once this transition is complete. Clients should prefer to 193ca95b02SDimitry Andric // deal with the Error value directly, rather than converting to error_code. 203ca95b02SDimitry Andric class CodeViewErrorCategory : public std::error_category { 213ca95b02SDimitry Andric public: name() const22d88c1a5aSDimitry Andric const char *name() const noexcept override { return "llvm.codeview"; } message(int Condition) const233ca95b02SDimitry Andric std::string message(int Condition) const override { 243ca95b02SDimitry Andric switch (static_cast<cv_error_code>(Condition)) { 253ca95b02SDimitry Andric case cv_error_code::unspecified: 26*b5893f02SDimitry Andric return "An unknown CodeView error has occurred."; 273ca95b02SDimitry Andric case cv_error_code::insufficient_buffer: 283ca95b02SDimitry Andric return "The buffer is not large enough to read the requested number of " 293ca95b02SDimitry Andric "bytes."; 303ca95b02SDimitry Andric case cv_error_code::corrupt_record: 313ca95b02SDimitry Andric return "The CodeView record is corrupted."; 327a7e6055SDimitry Andric case cv_error_code::no_records: 33*b5893f02SDimitry Andric return "There are no records."; 343ca95b02SDimitry Andric case cv_error_code::operation_unsupported: 353ca95b02SDimitry Andric return "The requested operation is not supported."; 36d88c1a5aSDimitry Andric case cv_error_code::unknown_member_record: 37d88c1a5aSDimitry Andric return "The member record is of an unknown type."; 383ca95b02SDimitry Andric } 393ca95b02SDimitry Andric llvm_unreachable("Unrecognized cv_error_code"); 403ca95b02SDimitry Andric } 413ca95b02SDimitry Andric }; 423ca95b02SDimitry Andric 43*b5893f02SDimitry Andric static llvm::ManagedStatic<CodeViewErrorCategory> CodeViewErrCategory; CVErrorCategory()44*b5893f02SDimitry Andricconst std::error_category &llvm::codeview::CVErrorCategory() { 45*b5893f02SDimitry Andric return *CodeViewErrCategory; 463ca95b02SDimitry Andric } 473ca95b02SDimitry Andric 48*b5893f02SDimitry Andric char CodeViewError::ID; 49