-
Notifications
You must be signed in to change notification settings - Fork 0
/
llvm_56379_workaround.hpp
40 lines (31 loc) · 1.36 KB
/
llvm_56379_workaround.hpp
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
#ifndef LLVM_56379_WORKAROUND_H
#define LLVM_56379_WORKAROUND_H
#if __has_include(<source_location>)
#include <source_location>
#endif // __has_include(<source_location>)
#if defined(__clang__) && (!__has_include(<source_location>) || !defined(__cpp_lib_source_location))
// Workaround for llvm/llvm-project#56379
namespace std {
class source_location {
private:
struct __impl {
char const *_M_file_name;
char const *_M_function_name;
std::uint_least32_t _M_line;
std::uint_least32_t _M_column;
} _M_impl;
public:
[[nodiscard]] constexpr source_location() noexcept = default;
[[nodiscard]] inline static /*HACK! consteval -> */ constexpr source_location current(__impl const *data = __builtin_source_location()) {
source_location result;
result._M_impl = *data;
return result;
}
[[nodiscard]] constexpr char const *file_name() const noexcept { return _M_impl._M_file_name; }
[[nodiscard]] constexpr char const *function_name() const noexcept { return _M_impl._M_function_name; }
[[nodiscard]] constexpr std::uint_least32_t column() const noexcept { return _M_impl._M_column; }
[[nodiscard]] constexpr std::uint_least32_t line() const noexcept { return _M_impl._M_line; }
};
} // namespace std
#endif // defined(__clang__) && (!__has_include(<source_location>) || !defined(__cpp_lib_source_location))
#endif // LLVM_56379_WORKAROUND_H