v8
8.4.371 (node 14.15.5)
V8 is Google's open source JavaScript engine
source-location.h
Go to the documentation of this file.
1
// Copyright 2020 the V8 project authors. All rights reserved.
2
// Use of this source code is governed by a BSD-style license that can be
3
// found in the LICENSE file.
4
5
#
ifndef
INCLUDE_CPPGC_SOURCE_LOCATION_H_
6
#
define
INCLUDE_CPPGC_SOURCE_LOCATION_H_
7
8
#
include
<
string
>
9
10
#
include
"v8config.h"
// NOLINT(build/include_directory)
11
12
#
if
defined
(
__has_builtin
)
13
#
define
CPPGC_SUPPORTS_SOURCE_LOCATION
14
(
__has_builtin
(
__builtin_FUNCTION
)
&&
__has_builtin
(
__builtin_FILE
)
&&
15
__has_builtin
(
__builtin_LINE
)
)
// NOLINT
16
#
elif
defined
(
V8_CC_GNU
)
&&
__GNUC__
>=
7
17
#
define
CPPGC_SUPPORTS_SOURCE_LOCATION
1
18
#
elif
defined
(
V8_CC_INTEL
)
&&
__ICC
>=
1800
19
#
define
CPPGC_SUPPORTS_SOURCE_LOCATION
1
20
#
else
21
#
define
CPPGC_SUPPORTS_SOURCE_LOCATION
0
22
#
endif
23
24
namespace
cppgc
{
25
26
// Encapsulates source location information. Mimics C++20's
27
// std::source_location.
28
class
V8_EXPORT
SourceLocation
final
{
29
public
:
30
#
if
CPPGC_SUPPORTS_SOURCE_LOCATION
31
static
constexpr
SourceLocation
Current(
32
const
char
* function =
__builtin_FUNCTION
(),
33
const
char
* file =
__builtin_FILE
(), size_t line =
__builtin_LINE
()) {
34
return
SourceLocation
(function, file, line);
35
}
36
#
else
37
static
constexpr
SourceLocation
Current
() {
return
SourceLocation
(); }
38
#
endif
// CPPGC_SUPPORTS_SOURCE_LOCATION
39
40
constexpr
SourceLocation
() =
default
;
41
42
constexpr
const
char
*
Function
()
const
{
return
function_; }
43
constexpr
const
char
*
FileName
()
const
{
return
file_; }
44
constexpr
size_t
Line
()
const
{
return
line_; }
45
46
std::string
ToString
()
const
;
47
48
private
:
49
constexpr
SourceLocation(
const
char
* function,
const
char
* file, size_t line)
50
: function_(function), file_(file), line_(line) {}
51
52
const
char
* function_ =
nullptr
;
53
const
char
* file_ =
nullptr
;
54
size_t line_ = 0u;
55
};
56
57
}
// namespace cppgc
58
59
#
endif
// INCLUDE_CPPGC_SOURCE_LOCATION_H_
include
cppgc
source-location.h
Generated on Fri Oct 29 2021 20:07:26 for v8 by
1.9.1