[InstCombine] Signed saturation tests. NFC
[llvm-complete.git] / include / llvm / Support / BinaryStreamError.h
blobcf6e034ffd2cebd0d906dc1157ad6d342cac9be6
1 //===- BinaryStreamError.h - Error extensions for Binary Streams *- C++ -*-===//
2 //
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
6 //
7 //===----------------------------------------------------------------------===//
9 #ifndef LLVM_SUPPORT_BINARYSTREAMERROR_H
10 #define LLVM_SUPPORT_BINARYSTREAMERROR_H
12 #include "llvm/ADT/StringRef.h"
13 #include "llvm/Support/Error.h"
15 #include <string>
17 namespace llvm {
18 enum class stream_error_code {
19 unspecified,
20 stream_too_short,
21 invalid_array_size,
22 invalid_offset,
23 filesystem_error
26 /// Base class for errors originating when parsing raw PDB files
27 class BinaryStreamError : public ErrorInfo<BinaryStreamError> {
28 public:
29 static char ID;
30 explicit BinaryStreamError(stream_error_code C);
31 explicit BinaryStreamError(StringRef Context);
32 BinaryStreamError(stream_error_code C, StringRef Context);
34 void log(raw_ostream &OS) const override;
35 std::error_code convertToErrorCode() const override;
37 StringRef getErrorMessage() const;
39 stream_error_code getErrorCode() const { return Code; }
41 private:
42 std::string ErrMsg;
43 stream_error_code Code;
45 } // namespace llvm
47 #endif // LLVM_SUPPORT_BINARYSTREAMERROR_H