mini-llvm
0.1.0
Toggle main menu visibility
Loading...
Searching...
No Matches
Diagnostic.h
Go to the documentation of this file.
1
// SPDX-License-Identifier: MIT
2
3
#pragma once
4
5
#include <cstddef>
6
#include <cstdlib>
7
#include <string>
8
#include <utility>
9
10
#include "
mini-llvm/utils/Color.h
"
11
12
namespace
mini_llvm
{
13
14
struct
Diagnostic
{
15
enum class
Level
{
16
kNote
,
17
kWarning
,
18
kError
,
19
};
20
21
Level
level
;
22
std::string
message
;
23
size_t
location
;
24
25
static
Diagnostic
note
(std::string
message
,
size_t
location
) {
26
return
{
Level::kNote
, std::move(
message
),
location
};
27
}
28
29
static
Diagnostic
warning
(std::string
message
,
size_t
location
) {
30
return
{
Level::kWarning
, std::move(
message
),
location
};
31
}
32
33
static
Diagnostic
error
(std::string
message
,
size_t
location
) {
34
return
{
Level::kError
, std::move(
message
),
location
};
35
}
36
};
37
38
inline
constexpr
const
char
*
name
(
Diagnostic::Level
level) {
39
using
enum
Diagnostic::Level
;
40
switch
(level) {
41
case
kNote:
return
"note"
;
42
case
kWarning:
return
"warning"
;
43
case
kError:
return
"error"
;
44
default
: abort();
45
}
46
}
47
48
inline
Color
color
(
Diagnostic::Level
level) {
49
using
enum
Diagnostic::Level
;
50
using namespace
colors
;
51
switch
(level) {
52
case
kNote:
return
cyan;
53
case
kWarning:
return
magenta;
54
case
kError:
return
red;
55
default
: abort();
56
}
57
}
58
59
}
// namespace mini_llvm
Color.h
mini_llvm::Color
Definition
Color.h:97
mini_llvm::colors
Definition
Color.h:170
mini_llvm
Definition
GraphColoringAllocator.h:13
mini_llvm::name
constexpr const char * name(Diagnostic::Level level)
Definition
Diagnostic.h:38
mini_llvm::color
Color color(Diagnostic::Level level)
Definition
Diagnostic.h:48
mini_llvm::Diagnostic
Definition
Diagnostic.h:14
mini_llvm::Diagnostic::message
std::string message
Definition
Diagnostic.h:22
mini_llvm::Diagnostic::error
static Diagnostic error(std::string message, size_t location)
Definition
Diagnostic.h:33
mini_llvm::Diagnostic::level
Level level
Definition
Diagnostic.h:21
mini_llvm::Diagnostic::warning
static Diagnostic warning(std::string message, size_t location)
Definition
Diagnostic.h:29
mini_llvm::Diagnostic::location
size_t location
Definition
Diagnostic.h:23
mini_llvm::Diagnostic::note
static Diagnostic note(std::string message, size_t location)
Definition
Diagnostic.h:25
mini_llvm::Diagnostic::Level
Level
Definition
Diagnostic.h:15
mini_llvm::Diagnostic::Level::kError
@ kError
Definition
Diagnostic.h:18
mini_llvm::Diagnostic::Level::kWarning
@ kWarning
Definition
Diagnostic.h:17
mini_llvm::Diagnostic::Level::kNote
@ kNote
Definition
Diagnostic.h:16
include
mini-llvm
common
Diagnostic.h
Generated by
1.17.0