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 a non-descript snippet execution failure. This class
40 // is designed to sub-classed into more specific failures that contain
41 // additional data about the specific error that they represent. Instead of
42 // halting the program, the errors are reported in the output.
43 class SnippetExecutionFailure
: public ErrorInfo
<SnippetExecutionFailure
> {
47 std::error_code
convertToErrorCode() const override
;
50 // A class representing specifically segmentation faults that happen during
52 class SnippetSegmentationFault
: public SnippetExecutionFailure
{
55 SnippetSegmentationFault(intptr_t SegFaultAddress
)
56 : Address(SegFaultAddress
){};
58 intptr_t getAddress() { return Address
; }
60 void log(raw_ostream
&OS
) const override
;
66 // A class representing all other non-specific failures that happen during
68 class SnippetSignal
: public SnippetExecutionFailure
{
71 SnippetSignal(int Signal
) : SignalNumber(Signal
){};
73 void log(raw_ostream
&OS
) const override
;
79 } // namespace exegesis