Mercurial > hg > CbC > CbC_llvm
comparison lib/Object/Error.cpp @ 148:63bd29f05246
merged
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Wed, 14 Aug 2019 19:46:37 +0900 |
parents | c2174574ed3a |
children |
comparison
equal
deleted
inserted
replaced
146:3fc4d5c3e21e | 148:63bd29f05246 |
---|---|
1 //===- Error.cpp - system_error extensions for Object -----------*- C++ -*-===// | 1 //===- Error.cpp - system_error extensions for Object -----------*- C++ -*-===// |
2 // | 2 // |
3 // The LLVM Compiler Infrastructure | 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
4 // | 4 // See https://llvm.org/LICENSE.txt for license information. |
5 // This file is distributed under the University of Illinois Open Source | 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
6 // License. See LICENSE.TXT for details. | |
7 // | 6 // |
8 //===----------------------------------------------------------------------===// | 7 //===----------------------------------------------------------------------===// |
9 // | 8 // |
10 // This defines a new error_category for the Object library. | 9 // This defines a new error_category for the Object library. |
11 // | 10 // |
55 } | 54 } |
56 llvm_unreachable("An enumerator of object_error does not have a message " | 55 llvm_unreachable("An enumerator of object_error does not have a message " |
57 "defined."); | 56 "defined."); |
58 } | 57 } |
59 | 58 |
59 void BinaryError::anchor() {} | |
60 char BinaryError::ID = 0; | 60 char BinaryError::ID = 0; |
61 char GenericBinaryError::ID = 0; | 61 char GenericBinaryError::ID = 0; |
62 | 62 |
63 GenericBinaryError::GenericBinaryError(Twine Msg) : Msg(Msg.str()) {} | 63 GenericBinaryError::GenericBinaryError(Twine Msg) : Msg(Msg.str()) {} |
64 | 64 |
76 const std::error_category &object::object_category() { | 76 const std::error_category &object::object_category() { |
77 return *error_category; | 77 return *error_category; |
78 } | 78 } |
79 | 79 |
80 llvm::Error llvm::object::isNotObjectErrorInvalidFileType(llvm::Error Err) { | 80 llvm::Error llvm::object::isNotObjectErrorInvalidFileType(llvm::Error Err) { |
81 if (auto Err2 = | 81 return handleErrors(std::move(Err), [](std::unique_ptr<ECError> M) -> Error { |
82 handleErrors(std::move(Err), [](std::unique_ptr<ECError> M) -> Error { | 82 // Try to handle 'M'. If successful, return a success value from |
83 // Try to handle 'M'. If successful, return a success value from | 83 // the handler. |
84 // the handler. | 84 if (M->convertToErrorCode() == object_error::invalid_file_type) |
85 if (M->convertToErrorCode() == object_error::invalid_file_type) | 85 return Error::success(); |
86 return Error::success(); | |
87 | 86 |
88 // We failed to handle 'M' - return it from the handler. | 87 // We failed to handle 'M' - return it from the handler. |
89 // This value will be passed back from catchErrors and | 88 // This value will be passed back from catchErrors and |
90 // wind up in Err2, where it will be returned from this function. | 89 // wind up in Err2, where it will be returned from this function. |
91 return Error(std::move(M)); | 90 return Error(std::move(M)); |
92 })) | 91 }); |
93 return Err2; | |
94 return Err; | |
95 } | 92 } |