blob: ebf4d65f20a91b31cbaf4e558a140cf7db2da6d5 [file] [log] [blame]
Lang Hamese7aad352016-03-23 23:57:28 +00001//===----- lib/Support/Error.cpp - Error and associated utilities ---------===//
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#include "llvm/Support/Error.h"
11#include "llvm/Support/ErrorHandling.h"
12#include "llvm/Support/ManagedStatic.h"
13
14using namespace llvm;
15
16namespace {
17
18 enum class ErrorErrorCode {
19 MultipleErrors
20 };
21
22 class ErrorErrorCategory : public std::error_category {
23 public:
24 const char *name() const LLVM_NOEXCEPT override { return "Error"; }
25
26 std::string message(int condition) const override {
27 switch (static_cast<ErrorErrorCode>(condition)) {
28 case ErrorErrorCode::MultipleErrors:
29 return "Multiple errors";
30 };
31 llvm_unreachable("Unhandled error code");
32 }
33 };
34
NAKAMURA Takumid8c1be62016-03-24 15:19:39 +000035}
Lang Hamese7aad352016-03-23 23:57:28 +000036
37void ErrorInfoBase::anchor() {}
38char ErrorInfoBase::ID = 0;
39
40static ManagedStatic<ErrorErrorCategory> ErrorErrorCat;
41
42std::error_code ErrorList::convertToErrorCode() const {
43 return std::error_code(static_cast<int>(ErrorErrorCode::MultipleErrors),
44 *ErrorErrorCat);
45}