1 //=-- SampleProf.cpp - Sample profiling format support --------------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file contains common definitions used in the reading and writing of
11 // sample profile data.
13 //===----------------------------------------------------------------------===//
15 #include "llvm/ProfileData/SampleProf.h"
16 #include "llvm/Support/ErrorHandling.h"
17 #include "llvm/Support/ManagedStatic.h"
22 class SampleProfErrorCategoryType
: public std::error_category
{
23 const char *name() const LLVM_NOEXCEPT override
{ return "llvm.sampleprof"; }
24 std::string
message(int IE
) const override
{
25 sampleprof_error E
= static_cast<sampleprof_error
>(IE
);
27 case sampleprof_error::success
:
29 case sampleprof_error::bad_magic
:
30 return "Invalid file format (bad magic)";
31 case sampleprof_error::unsupported_version
:
32 return "Unsupported format version";
33 case sampleprof_error::too_large
:
34 return "Too much profile data";
35 case sampleprof_error::truncated
:
36 return "Truncated profile data";
37 case sampleprof_error::malformed
:
38 return "Malformed profile data";
39 case sampleprof_error::unrecognized_format
:
40 return "Unrecognized profile encoding format";
42 llvm_unreachable("A value of sampleprof_error has no message.");
47 static ManagedStatic
<SampleProfErrorCategoryType
> ErrorCategory
;
49 const std::error_category
&llvm::sampleprof_category() {
50 return *ErrorCategory
;