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