2016-03-24 07:57:28 +08:00
|
|
|
//===----- lib/Support/Error.cpp - Error and associated utilities ---------===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "llvm/Support/Error.h"
|
|
|
|
#include "llvm/Support/ErrorHandling.h"
|
|
|
|
#include "llvm/Support/ManagedStatic.h"
|
|
|
|
|
|
|
|
using namespace llvm;
|
|
|
|
|
|
|
|
namespace {
|
|
|
|
|
|
|
|
enum class ErrorErrorCode {
|
|
|
|
MultipleErrors
|
|
|
|
};
|
|
|
|
|
|
|
|
class ErrorErrorCategory : public std::error_category {
|
|
|
|
public:
|
|
|
|
const char *name() const LLVM_NOEXCEPT override { return "Error"; }
|
|
|
|
|
|
|
|
std::string message(int condition) const override {
|
|
|
|
switch (static_cast<ErrorErrorCode>(condition)) {
|
|
|
|
case ErrorErrorCode::MultipleErrors:
|
|
|
|
return "Multiple errors";
|
|
|
|
};
|
|
|
|
llvm_unreachable("Unhandled error code");
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2016-03-24 23:19:39 +08:00
|
|
|
}
|
2016-03-24 07:57:28 +08:00
|
|
|
|
|
|
|
void ErrorInfoBase::anchor() {}
|
|
|
|
char ErrorInfoBase::ID = 0;
|
2016-03-25 07:49:34 +08:00
|
|
|
char ErrorList::ID = 0;
|
|
|
|
char ECError::ID = 0;
|
2016-03-24 23:26:43 +08:00
|
|
|
|
2016-03-24 07:57:28 +08:00
|
|
|
static ManagedStatic<ErrorErrorCategory> ErrorErrorCat;
|
|
|
|
|
|
|
|
std::error_code ErrorList::convertToErrorCode() const {
|
|
|
|
return std::error_code(static_cast<int>(ErrorErrorCode::MultipleErrors),
|
|
|
|
*ErrorErrorCat);
|
|
|
|
}
|