[llvm] [cmake] Add possibility to use ChooseMSVCCRT.cmake when include LLVM library
[llvm-core.git] / include / llvm / DebugInfo / PDB / GenericError.h
blobec85d92d2a9273349b26bc4551db106f52c86367
1 //===- GenericError.h - system_error extensions for PDB ---------*- 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_DEBUGINFO_PDB_ERROR_H
10 #define LLVM_DEBUGINFO_PDB_ERROR_H
12 #include "llvm/ADT/StringRef.h"
13 #include "llvm/Support/Error.h"
15 namespace llvm {
16 namespace pdb {
18 enum class pdb_error_code {
19 invalid_utf8_path = 1,
20 dia_sdk_not_present,
21 dia_failed_loading,
22 signature_out_of_date,
23 external_cmdline_ref,
24 unspecified,
26 } // namespace pdb
27 } // namespace llvm
29 namespace std {
30 template <>
31 struct is_error_code_enum<llvm::pdb::pdb_error_code> : std::true_type {};
32 } // namespace std
34 namespace llvm {
35 namespace pdb {
36 const std::error_category &PDBErrCategory();
38 inline std::error_code make_error_code(pdb_error_code E) {
39 return std::error_code(static_cast<int>(E), PDBErrCategory());
42 /// Base class for errors originating when parsing raw PDB files
43 class PDBError : public ErrorInfo<PDBError, StringError> {
44 public:
45 using ErrorInfo<PDBError, StringError>::ErrorInfo; // inherit constructors
46 PDBError(const Twine &S) : ErrorInfo(S, pdb_error_code::unspecified) {}
47 static char ID;
49 } // namespace pdb
50 } // namespace llvm
51 #endif