1 //===-- Error.h -------------------------------------------------*- C++ -*-===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 #ifndef LLVM_TOOLS_LLVM_EXEGESIS_ERROR_H
10 #define LLVM_TOOLS_LLVM_EXEGESIS_ERROR_H
12 #include "llvm/ADT/Twine.h"
13 #include "llvm/Support/Error.h"
18 // A class representing failures that happened within llvm-exegesis, they are
19 // used to report informations to the user.
20 class Failure
: public StringError
{
22 Failure(const Twine
&S
) : StringError(S
, inconvertibleErrorCode()) {}
25 // A class representing failures that happened during clustering calculations.
26 class ClusteringError
: public ErrorInfo
<ClusteringError
> {
29 ClusteringError(const Twine
&S
) : Msg(S
.str()) {}
31 void log(raw_ostream
&OS
) const override
;
33 std::error_code
convertToErrorCode() const override
;
39 // A class representing failures that happened during snippet execution.
40 // Instead of terminating the program crashes are logged into the output.
41 class SnippetCrash
: public ErrorInfo
<SnippetCrash
> {
44 SnippetCrash(const Twine
&S
) : Msg(S
.str()) {}
46 void log(raw_ostream
&OS
) const override
;
48 std::error_code
convertToErrorCode() const override
;
54 } // namespace exegesis