LLVM  6.0.0svn
DIAError.cpp
Go to the documentation of this file.
4 
5 using namespace llvm;
6 using namespace llvm::pdb;
7 
8 // FIXME: This class is only here to support the transition to llvm::Error. It
9 // will be removed once this transition is complete. Clients should prefer to
10 // deal with the Error value directly, rather than converting to error_code.
12 public:
13  const char *name() const noexcept override { return "llvm.pdb.dia"; }
14 
15  std::string message(int Condition) const override {
16  switch (static_cast<dia_error_code>(Condition)) {
18  return "Failed to connect to DIA at runtime. Verify that Visual Studio "
19  "is properly installed, or that msdiaXX.dll is in your PATH.";
21  return "Unable to load PDB. The file has an unrecognized format.";
23  return "The parameter is incorrect.";
25  return "Unable to load the PDB or EXE, because it is already loaded.";
27  return "The PDB file and the EXE file do not match.";
29  return "An unknown error has occurred.";
30  }
31  llvm_unreachable("Unrecognized DIAErrorCode");
32  }
33 };
34 
36 
37 char DIAError::ID = 0;
38 
40 
42  : DIAError(dia_error_code::unspecified, Context) {}
43 
45  ErrMsg = "DIA Error: ";
46  std::error_code EC = convertToErrorCode();
47  ErrMsg += EC.message() + " ";
48  if (!Context.empty())
49  ErrMsg += Context;
50 }
51 
52 void DIAError::log(raw_ostream &OS) const { OS << ErrMsg << "\n"; }
53 
54 StringRef DIAError::getErrorMessage() const { return ErrMsg; }
55 
56 std::error_code DIAError::convertToErrorCode() const {
57  return std::error_code(static_cast<int>(Code), *Category);
58 }
uint64_t CallInst * C
LLVMContext & Context
Compute iterated dominance frontiers using a linear time algorithm.
Definition: AllocatorList.h:24
std::error_code convertToErrorCode() const override
Convert this error to a std::error_code.
Definition: DIAError.cpp:56
DIAError(dia_error_code C)
Definition: DIAError.cpp:39
dia_error_code
Definition: DIAError.h:18
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE bool empty() const
empty - Check if the string is empty.
Definition: StringRef.h:133
StringRef getErrorMessage() const
Definition: DIAError.cpp:54
static char ID
Definition: DIAError.h:30
static ManagedStatic< _object_error_category > error_category
Definition: Error.cpp:74
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
std::string message(int Condition) const override
Definition: DIAError.cpp:15
const char * name() const noexcept override
Definition: DIAError.cpp:13
static ManagedStatic< DIAErrorCategory > Category
Definition: DIAError.cpp:35
aarch64 promote const
Base class for errors originating in DIA SDK, e.g. COM calls.
Definition: DIAError.h:28
This class implements an extremely fast bulk output stream that can only output to a stream...
Definition: raw_ostream.h:44
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:49
ManagedStatic - This transparently changes the behavior of global statics to be lazily constructed on...
Definition: ManagedStatic.h:61
void log(raw_ostream &OS) const override
Print an error message to an output stream.
Definition: DIAError.cpp:52