1819e77d1SZachary Turner //===- Error.cpp - system_error extensions for PDB --------------*- C++ -*-===// 2819e77d1SZachary Turner // 32946cd70SChandler Carruth // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 42946cd70SChandler Carruth // See https://llvm.org/LICENSE.txt for license information. 52946cd70SChandler Carruth // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6819e77d1SZachary Turner // 7819e77d1SZachary Turner //===----------------------------------------------------------------------===// 8819e77d1SZachary Turner 9819e77d1SZachary Turner #include "llvm/DebugInfo/PDB/GenericError.h" 10819e77d1SZachary Turner #include "llvm/Support/ErrorHandling.h" 11819e77d1SZachary Turner 12819e77d1SZachary Turner using namespace llvm; 13819e77d1SZachary Turner using namespace llvm::pdb; 14819e77d1SZachary Turner 15711950c1SBenjamin Kramer namespace { 164718f8b5SPeter Collingbourne // FIXME: This class is only here to support the transition to llvm::Error. It 174718f8b5SPeter Collingbourne // will be removed once this transition is complete. Clients should prefer to 184718f8b5SPeter Collingbourne // deal with the Error value directly, rather than converting to error_code. 196a7efef4SAlexandre Ganea class PDBErrorCategory : public std::error_category { 20819e77d1SZachary Turner public: name() const21990504e6SReid Kleckner const char *name() const noexcept override { return "llvm.pdb"; } message(int Condition) const22819e77d1SZachary Turner std::string message(int Condition) const override { 236a7efef4SAlexandre Ganea switch (static_cast<pdb_error_code>(Condition)) { 246a7efef4SAlexandre Ganea case pdb_error_code::unspecified: 25819e77d1SZachary Turner return "An unknown error has occurred."; 266a7efef4SAlexandre Ganea case pdb_error_code::dia_sdk_not_present: 27819e77d1SZachary Turner return "LLVM was not compiled with support for DIA. This usually means " 289ff2380eSHiroshi Inoue "that you are not using MSVC, or your Visual Studio " 296a7efef4SAlexandre Ganea "installation is corrupt."; 306a7efef4SAlexandre Ganea case pdb_error_code::dia_failed_loading: 316a7efef4SAlexandre Ganea return "DIA is only supported when using MSVC."; 326a7efef4SAlexandre Ganea case pdb_error_code::invalid_utf8_path: 336a7efef4SAlexandre Ganea return "The PDB file path is an invalid UTF8 sequence."; 346a7efef4SAlexandre Ganea case pdb_error_code::signature_out_of_date: 35d93b07f0SAlexandre Ganea return "The signature does not match; the file(s) might be out of date."; 3602c53868SZachary Turner case pdb_error_code::no_matching_pch: 3702c53868SZachary Turner return "No matching precompiled header could be located."; 38819e77d1SZachary Turner } 39819e77d1SZachary Turner llvm_unreachable("Unrecognized generic_error_code"); 40819e77d1SZachary Turner } 41819e77d1SZachary Turner }; 42711950c1SBenjamin Kramer } // namespace 43819e77d1SZachary Turner PDBErrCategory()44*ede60037SNicolai Hähnleconst std::error_category &llvm::pdb::PDBErrCategory() { 45*ede60037SNicolai Hähnle static PDBErrorCategory PDBCategory; 46*ede60037SNicolai Hähnle return PDBCategory; 47*ede60037SNicolai Hähnle } 48819e77d1SZachary Turner 496a7efef4SAlexandre Ganea char PDBError::ID; 50