blob: 027fa81790b6990f706a4d424f969e14bf654481 [file] [log] [blame]
Diego Novilloc572e922014-10-30 18:00:06 +00001//=-- SampleProf.cpp - Sample profiling format support --------------------===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
10// This file contains common definitions used in the reading and writing of
11// sample profile data.
12//
13//===----------------------------------------------------------------------===//
14
15#include "llvm/ProfileData/SampleProf.h"
16#include "llvm/Support/ErrorHandling.h"
17#include "llvm/Support/ManagedStatic.h"
18
19using namespace llvm;
20
21namespace {
22class 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);
26 switch (E) {
27 case sampleprof_error::success:
28 return "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";
Diego Novillod5336ae2014-11-01 00:56:55 +000039 case sampleprof_error::unrecognized_format:
40 return "Unrecognized profile encoding format";
Diego Novillo3376a782015-09-17 00:17:24 +000041 case sampleprof_error::not_implemented:
42 return "Unimplemented feature";
Diego Novilloc572e922014-10-30 18:00:06 +000043 }
44 llvm_unreachable("A value of sampleprof_error has no message.");
45 }
46};
Alexander Kornienkof00654e2015-06-23 09:49:53 +000047}
Diego Novilloc572e922014-10-30 18:00:06 +000048
49static ManagedStatic<SampleProfErrorCategoryType> ErrorCategory;
50
51const std::error_category &llvm::sampleprof_category() {
52 return *ErrorCategory;
53}