2018-07-23 20:09:43 +02:00
|
|
|
//===- Error.cpp - system_error extensions for llvm-cxxdump -----*- C++ -*-===//
|
2014-07-25 01:14:40 +02:00
|
|
|
//
|
2019-01-19 09:50:56 +01:00
|
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
2014-07-25 01:14:40 +02:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
2015-03-15 02:30:58 +01:00
|
|
|
// This defines a new error_category for the llvm-cxxdump tool.
|
2014-07-25 01:14:40 +02:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "Error.h"
|
|
|
|
#include "llvm/Support/ErrorHandling.h"
|
|
|
|
|
|
|
|
using namespace llvm;
|
|
|
|
|
|
|
|
namespace {
|
2016-05-24 22:13:46 +02:00
|
|
|
// FIXME: This class is only here to support the transition to llvm::Error. It
|
|
|
|
// will be removed once this transition is complete. Clients should prefer to
|
|
|
|
// deal with the Error value directly, rather than converting to error_code.
|
2015-03-15 02:30:58 +01:00
|
|
|
class cxxdump_error_category : public std::error_category {
|
2014-07-25 01:14:40 +02:00
|
|
|
public:
|
2016-10-20 01:52:38 +02:00
|
|
|
const char *name() const noexcept override { return "llvm.cxxdump"; }
|
2014-07-25 01:14:40 +02:00
|
|
|
std::string message(int ev) const override {
|
2015-03-15 02:30:58 +01:00
|
|
|
switch (static_cast<cxxdump_error>(ev)) {
|
|
|
|
case cxxdump_error::success:
|
2014-07-25 01:14:40 +02:00
|
|
|
return "Success";
|
2015-03-15 02:30:58 +01:00
|
|
|
case cxxdump_error::file_not_found:
|
2014-07-25 01:14:40 +02:00
|
|
|
return "No such file.";
|
2015-03-15 02:30:58 +01:00
|
|
|
case cxxdump_error::unrecognized_file_format:
|
2014-07-25 01:14:40 +02:00
|
|
|
return "Unrecognized file type.";
|
|
|
|
}
|
|
|
|
llvm_unreachable(
|
2015-03-15 02:30:58 +01:00
|
|
|
"An enumerator of cxxdump_error does not have a message defined.");
|
2014-07-25 01:14:40 +02:00
|
|
|
}
|
|
|
|
};
|
|
|
|
} // namespace
|
|
|
|
|
|
|
|
namespace llvm {
|
2015-03-15 02:30:58 +01:00
|
|
|
const std::error_category &cxxdump_category() {
|
|
|
|
static cxxdump_error_category o;
|
2014-07-25 01:14:40 +02:00
|
|
|
return o;
|
|
|
|
}
|
|
|
|
} // namespace llvm
|