1 //===- Error.cpp - system_error extensions for llvm-vtabledump --*- C++ -*-===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is distributed under the University of Illinois Open Source 6 // License. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 // 10 // This defines a new error_category for the llvm-vtabledump tool. 11 // 12 //===----------------------------------------------------------------------===// 13 14 #include "Error.h" 15 #include "llvm/Support/ErrorHandling.h" 16 17 using namespace llvm; 18 19 namespace { 20 class vtabledump_error_category : public std::error_category { 21 public: name() const22 const char *name() const LLVM_NOEXCEPT override { return "llvm.vtabledump"; } message(int ev) const23 std::string message(int ev) const override { 24 switch (static_cast<vtabledump_error>(ev)) { 25 case vtabledump_error::success: 26 return "Success"; 27 case vtabledump_error::file_not_found: 28 return "No such file."; 29 case vtabledump_error::unrecognized_file_format: 30 return "Unrecognized file type."; 31 } 32 llvm_unreachable( 33 "An enumerator of vtabledump_error does not have a message defined."); 34 } 35 }; 36 } // namespace 37 38 namespace llvm { vtabledump_category()39const std::error_category &vtabledump_category() { 40 static vtabledump_error_category o; 41 return o; 42 } 43 } // namespace llvm 44