1 //===- Error.cpp - system_error extensions for llvm-cxxdump -----*- C++ -*-===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 // This defines a new error_category for the llvm-cxxdump tool.
11 //===----------------------------------------------------------------------===//
14 #include "llvm/Support/ErrorHandling.h"
20 // FIXME: This class is only here to support the transition to llvm::Error. It
21 // will be removed once this transition is complete. Clients should prefer to
22 // deal with the Error value directly, rather than converting to error_code.
23 class cxxdump_error_category
: public std::error_category
{
25 const char *name() const noexcept override
{ return "llvm.cxxdump"; }
26 std::string
message(int ev
) const override
{
27 switch (static_cast<cxxdump_error
>(ev
)) {
28 case cxxdump_error::success
:
30 case cxxdump_error::file_not_found
:
31 return "No such file.";
32 case cxxdump_error::unrecognized_file_format
:
33 return "Unrecognized file type.";
36 "An enumerator of cxxdump_error does not have a message defined.");
42 const std::error_category
&cxxdump_category() {
43 static cxxdump_error_category o
;