Path: blob/main/contrib/llvm-project/llvm/tools/llvm-cxxdump/Error.cpp
35258 views
//===- Error.cpp - system_error extensions for llvm-cxxdump -----*- C++ -*-===//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===----------------------------------------------------------------------===//7//8// This defines a new error_category for the llvm-cxxdump tool.9//10//===----------------------------------------------------------------------===//1112#include "Error.h"13#include "llvm/Support/ErrorHandling.h"14#include <string>1516using namespace llvm;1718namespace {19// FIXME: This class is only here to support the transition to llvm::Error. It20// will be removed once this transition is complete. Clients should prefer to21// deal with the Error value directly, rather than converting to error_code.22class cxxdump_error_category : public std::error_category {23public:24const char *name() const noexcept override { return "llvm.cxxdump"; }25std::string message(int ev) const override {26switch (static_cast<cxxdump_error>(ev)) {27case cxxdump_error::success:28return "Success";29case cxxdump_error::file_not_found:30return "No such file.";31case cxxdump_error::unrecognized_file_format:32return "Unrecognized file type.";33}34llvm_unreachable(35"An enumerator of cxxdump_error does not have a message defined.");36}37};38} // namespace3940namespace llvm {41const std::error_category &cxxdump_category() {42static cxxdump_error_category o;43return o;44}45} // namespace llvm464748