Thorin 1.9.0
The Higher ORder INtermediate representation
Loading...
Searching...
No Matches
dbg.h
Go to the documentation of this file.
1#pragma once
2
3#include <filesystem>
4
5#include <absl/container/flat_hash_map.h>
6#include <absl/container/flat_hash_set.h>
7#include <fe/loc.h>
8#include <fe/sym.h>
9
10#include "thorin/util/print.h"
11
12namespace thorin {
13
14namespace fs = std::filesystem;
15
16using fe::Loc;
17using fe::Pos;
18using fe::Sym;
19
20/// @name Formatted Output
21///@{
22/// Prefixes error message with `<location>: error: `.
23template<class T = std::logic_error, class... Args> [[noreturn]] void error(Loc loc, const char* fmt, Args&&... args) {
24 std::ostringstream o;
25 print(o, "{}: error: ", loc);
26 print(o, fmt, std::forward<Args&&>(args)...);
27 throw T(o.str());
28}
29///@}
30
31struct Dbg {
32 Loc loc;
33 Sym sym;
34};
35
36} // namespace thorin
Definition cfg.h:11
void error(const Def *def, const char *fmt, Args &&... args)
Definition def.h:622
std::ostream & print(std::ostream &os, const char *s)
Base case.
Definition print.cpp:5
Loc loc
Definition dbg.h:32
std::string fmt(const char *s, Args &&... args)
Wraps thorin::print to output a formatted std:string.
Definition print.h:144
Sym sym
Definition dbg.h:33