2
0

Error.cpp 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. //===- Error.cxx - system_error extensions for llvm-cxxdump -----*- 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-cxxdump tool.
  11. //
  12. //===----------------------------------------------------------------------===//
  13. #include "Error.h"
  14. #include "llvm/Support/ErrorHandling.h"
  15. using namespace llvm;
  16. namespace {
  17. class cxxdump_error_category : public std::error_category {
  18. public:
  19. const char *name() const LLVM_NOEXCEPT override { return "llvm.cxxdump"; }
  20. std::string message(int ev) const override {
  21. switch (static_cast<cxxdump_error>(ev)) {
  22. case cxxdump_error::success:
  23. return "Success";
  24. case cxxdump_error::file_not_found:
  25. return "No such file.";
  26. case cxxdump_error::unrecognized_file_format:
  27. return "Unrecognized file type.";
  28. }
  29. llvm_unreachable(
  30. "An enumerator of cxxdump_error does not have a message defined.");
  31. }
  32. };
  33. } // namespace
  34. namespace llvm {
  35. const std::error_category &cxxdump_category() {
  36. static cxxdump_error_category o;
  37. return o;
  38. }
  39. } // namespace llvm