GenericError.cpp 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. //===- Error.cpp - 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. //===----------------------------------------------------------------------===//
  8. #include "llvm/DebugInfo/PDB/GenericError.h"
  9. #include "llvm/Support/ErrorHandling.h"
  10. using namespace llvm;
  11. using namespace llvm::pdb;
  12. namespace {
  13. // FIXME: This class is only here to support the transition to llvm::Error. It
  14. // will be removed once this transition is complete. Clients should prefer to
  15. // deal with the Error value directly, rather than converting to error_code.
  16. class PDBErrorCategory : public std::error_category {
  17. public:
  18. const char *name() const noexcept override { return "llvm.pdb"; }
  19. std::string message(int Condition) const override {
  20. switch (static_cast<pdb_error_code>(Condition)) {
  21. case pdb_error_code::unspecified:
  22. return "An unknown error has occurred.";
  23. case pdb_error_code::dia_sdk_not_present:
  24. return "LLVM was not compiled with support for DIA. This usually means "
  25. "that you are not using MSVC, or your Visual Studio "
  26. "installation is corrupt.";
  27. case pdb_error_code::dia_failed_loading:
  28. return "DIA is only supported when using MSVC.";
  29. case pdb_error_code::invalid_utf8_path:
  30. return "The PDB file path is an invalid UTF8 sequence.";
  31. case pdb_error_code::signature_out_of_date:
  32. return "The signature does not match; the file(s) might be out of date.";
  33. case pdb_error_code::no_matching_pch:
  34. return "No matching precompiled header could be located.";
  35. }
  36. llvm_unreachable("Unrecognized generic_error_code");
  37. }
  38. };
  39. } // namespace
  40. const std::error_category &llvm::pdb::PDBErrCategory() {
  41. static PDBErrorCategory PDBCategory;
  42. return PDBCategory;
  43. }
  44. char PDBError::ID;