5#ifndef INCLUDE_CPPGC_SOURCE_LOCATION_H_
6#define INCLUDE_CPPGC_SOURCE_LOCATION_H_
13#if defined(__has_builtin)
14#define CPPGC_SUPPORTS_SOURCE_LOCATION \
15 (__has_builtin(__builtin_FUNCTION) && __has_builtin(__builtin_FILE) && \
16 __has_builtin(__builtin_LINE))
17#elif defined(V8_CC_GNU) && __GNUC__ >= 7
18#define CPPGC_SUPPORTS_SOURCE_LOCATION 1
19#elif defined(V8_CC_INTEL) && __ICC >= 1800
20#define CPPGC_SUPPORTS_SOURCE_LOCATION 1
22#define CPPGC_SUPPORTS_SOURCE_LOCATION 0
37#if CPPGC_SUPPORTS_SOURCE_LOCATION
39 const char* function = __builtin_FUNCTION(),
40 const char* file = __builtin_FILE(),
size_t line = __builtin_LINE()) {
58 constexpr const char*
Function()
const {
return function_; }
65 constexpr const char*
FileName()
const {
return file_; }
72 constexpr size_t Line()
const {
return line_; }
82 constexpr SourceLocation(
const char* function,
const char* file,
size_t line)
83 : function_(function), file_(file), line_(line) {}
85 const char* function_ =
nullptr;
86 const char* file_ =
nullptr;
constexpr size_t Line() const
std::string ToString() const
constexpr SourceLocation()=default
constexpr const char * FileName() const
constexpr const char * Function() const
static constexpr SourceLocation Current()