Line data Source code
1 : //===- Error.cpp - system_error extensions for PDB --------------*- C++ -*-===//
2 : //
3 : // The LLVM Compiler Infrastructure
4 : //
5 : // This file is distributed under the University of Illinois Open Source
6 : // License. See LICENSE.TXT for details.
7 : //
8 : //===----------------------------------------------------------------------===//
9 :
10 : #include "llvm/DebugInfo/PDB/GenericError.h"
11 : #include "llvm/Support/ErrorHandling.h"
12 : #include "llvm/Support/ManagedStatic.h"
13 :
14 : using namespace llvm;
15 : using namespace llvm::pdb;
16 :
17 : // FIXME: This class is only here to support the transition to llvm::Error. It
18 : // will be removed once this transition is complete. Clients should prefer to
19 : // deal with the Error value directly, rather than converting to error_code.
20 1 : class PDBErrorCategory : public std::error_category {
21 : public:
22 0 : const char *name() const noexcept override { return "llvm.pdb"; }
23 2 : std::string message(int Condition) const override {
24 2 : switch (static_cast<pdb_error_code>(Condition)) {
25 : case pdb_error_code::unspecified:
26 0 : return "An unknown error has occurred.";
27 : case pdb_error_code::type_server_not_found:
28 0 : return "Type server PDB was not found.";
29 : case pdb_error_code::dia_sdk_not_present:
30 : return "LLVM was not compiled with support for DIA. This usually means "
31 : "that you are not using MSVC, or your Visual Studio "
32 0 : "installation is corrupt.";
33 : case pdb_error_code::dia_failed_loading:
34 0 : return "DIA is only supported when using MSVC.";
35 : case pdb_error_code::invalid_utf8_path:
36 0 : return "The PDB file path is an invalid UTF8 sequence.";
37 : case pdb_error_code::signature_out_of_date:
38 2 : return "The signature does not match; the file(s) might be out of date.";
39 : }
40 0 : llvm_unreachable("Unrecognized generic_error_code");
41 : }
42 : };
43 :
44 : static llvm::ManagedStatic<PDBErrorCategory> PDBCategory;
45 1 : const std::error_category &llvm::pdb::PDBErrCategory() { return *PDBCategory; }
46 :
47 : char PDBError::ID;
|