File: error.h

package info (click to toggle)
muon-meson 0.5.0-1.1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 13,532 kB
  • sloc: ansic: 67,766; python: 4,391; cpp: 1,983; sh: 709; javascript: 570; asm: 226; xml: 67; objc: 36; makefile: 29; modula3: 8; f90: 7
file content (67 lines) | stat: -rw-r--r-- 2,425 bytes parent folder | download
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
/*
 * SPDX-FileCopyrightText: Stone Tickle <lattis@mochiro.moe>
 * SPDX-License-Identifier: GPL-3.0-only
 */

#ifndef MUON_ERROR_H
#define MUON_ERROR_H

#include "compat.h"

#include "lang/types.h"
#include "log.h"
#include "platform/filesystem.h"

#define UNREACHABLE assert(false && "unreachable")
#define UNREACHABLE_RETURN                      \
	do {                                    \
		assert(false && "unreachable"); \
		return 0;                       \
	} while (0)

enum error_diagnostic_store_replay_opts {
	error_diagnostic_store_replay_errors_only = 1 << 0,
	error_diagnostic_store_replay_dont_include_sources = 1 << 1,
	error_diagnostic_store_replay_werror = 1 << 2,
	error_diagnostic_store_replay_prepare_only = 1 << 3,
};

struct error_diagnostic_message {
	struct source_location location;
	enum log_level lvl;
	const char *msg;
	uint32_t src_idx;
};

void error_unrecoverable(const char *fmt, ...) MUON_ATTR_FORMAT(printf, 1, 2);
void error_message(const struct source *src, struct source_location location, enum log_level lvl, enum error_message_flag flags, const char *msg);
void error_message_flush_coalesced_message(void);
void
error_messagev(const struct source *src, struct source_location location, enum log_level lvl, const char *fmt, va_list args);
void error_messagef(const struct source *src, struct source_location location, enum log_level lvl, const char *fmt, ...)
	MUON_ATTR_FORMAT(printf, 4, 5);

void error_diagnostic_store_init(struct workspace *wk);
void error_diagnostic_store_destroy(struct workspace *wk);
struct arr *error_diagnostic_store_get(void);
bool error_diagnostic_store_replay(struct workspace *wk, enum error_diagnostic_store_replay_opts opts);
void
error_diagnostic_store_push(uint32_t src_idx, struct source_location location, enum log_level lvl, const char *msg);
void list_line_range(const struct source *src, struct source_location location, uint32_t context);

void reopen_source(const struct source *src, struct source *src_reopened, bool *destroy_source);

struct detailed_source_location {
	struct source_location loc;
	uint32_t line, col, start_of_line, end_line, end_col;
};

enum get_detailed_source_location_flag {
	get_detailed_source_location_flag_multiline = 1 << 0,
};

void get_detailed_source_location(const struct source *src,
	struct source_location loc,
	struct detailed_source_location *dloc,
	enum get_detailed_source_location_flag flags);
#endif