diff options
Diffstat (limited to 'llvm/include/llvm/ProfileData/ProfileCommon.h')
-rw-r--r-- | llvm/include/llvm/ProfileData/ProfileCommon.h | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/llvm/include/llvm/ProfileData/ProfileCommon.h b/llvm/include/llvm/ProfileData/ProfileCommon.h index ae196aa5d00..c367b5951c4 100644 --- a/llvm/include/llvm/ProfileData/ProfileCommon.h +++ b/llvm/include/llvm/ProfileData/ProfileCommon.h @@ -21,6 +21,7 @@ #include <vector> #include "llvm/Support/Casting.h" +#include "llvm/Support/Error.h" namespace llvm { class Function; @@ -36,6 +37,29 @@ class Metadata; class MDTuple; class MDNode; +template <typename ErrT> +class ProfErrorInfoBase : public ErrorInfo<ProfErrorInfoBase<ErrT>> { +public: + ProfErrorInfoBase(ErrT Err) : Err(Err) { + assert(Err != ErrT::success && "Not an error"); + } + + virtual std::string message() const override = 0; + + void log(raw_ostream &OS) const override { OS << message(); } + + std::error_code convertToErrorCode() const override { + return make_error_code(Err); + } + + ErrT get() const { return Err; } + + static char ID; + +protected: + ErrT Err; +}; + inline const char *getHotSectionPrefix() { return ".hot"; } inline const char *getUnlikelySectionPrefix() { return ".unlikely"; } |