This repository was archived by the owner on Jan 8, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathError.h
More file actions
69 lines (56 loc) · 1.71 KB
/
Error.h
File metadata and controls
69 lines (56 loc) · 1.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#pragma once
#include "Config/Config.h"
#include "Support/LLVM.h"
inline void reportError(const llvm::Twine &reason) {
#ifdef DEBUG_MODE
llvm::report_fatal_error(reason);
#else
llvm::errs() << reason << '\n';
abort();
#endif
}
inline void reportOnError(bool condition, const llvm::Twine &reason) {
if (condition) {
reportError(reason);
}
}
inline void reportTypeError(const llvm::Twine &reason) {
reportError(llvm::formatv("[Compilation Type Error] {0}", reason));
}
inline void reportOnTypeError(bool condition, const llvm::Twine &reason) {
if (condition) {
reportTypeError(reason);
}
}
inline void reportSemanticError(const llvm::Twine &reason) {
reportError(llvm::formatv("[Compilation Semantic Error] {0}", reason));
}
inline void reportOnSemanticError(bool condition, const llvm::Twine &reason) {
if (condition) {
reportSemanticError(reason);
}
}
inline void reportLinkError(const llvm::Twine &reason) {
reportError(llvm::formatv("[Compilation Link Error] {0}", reason));
}
inline void reportOnLinkError(bool condition, const llvm::Twine &reason) {
if (condition) {
reportLinkError(reason);
}
}
inline void reportCodeGenError(const llvm::Twine &reason) {
reportError(llvm::formatv("[Compilation CodeGen Error] {0}", reason));
}
inline void reportOnCodeGenError(bool condition, const llvm::Twine &reason) {
if (condition) {
reportCodeGenError(reason);
}
}
inline void reportDriverError(const llvm::Twine &reason) {
reportError(llvm::formatv("[Compilation Driver Error] {0}", reason));
}
inline void reportOnDriverError(bool condition, const llvm::Twine &reason) {
if (condition) {
reportDriverError(reason);
}
}