5#ifndef INCLUDE_CPPGC_INTERNAL_NAME_TRAIT_H_
6#define INCLUDE_CPPGC_INTERNAL_NAME_TRAIT_H_
18#if CPPGC_SUPPORTS_OBJECT_NAMES && defined(__clang__)
19#define CPPGC_SUPPORTS_COMPILE_TIME_TYPENAME 1
25 char name[Size + 1]{};
27 static constexpr NameBuffer FromCString(
const char* str) {
29 for (
size_t i = 0; i < Size; ++i) result.name[i] = str[i];
30 result.name[Size] = 0;
36const char* GetTypename() {
37 static constexpr char kSelfPrefix[] =
38 "const char *cppgc::internal::GetTypename() [T =";
39 static_assert(__builtin_strncmp(__PRETTY_FUNCTION__, kSelfPrefix,
40 sizeof(kSelfPrefix) - 1) == 0,
41 "The prefix must match");
42 static constexpr const char* kTypenameStart =
43 __PRETTY_FUNCTION__ +
sizeof(kSelfPrefix);
44 static constexpr size_t kTypenameSize =
45 __builtin_strlen(__PRETTY_FUNCTION__) -
sizeof(kSelfPrefix) - 1;
48 static constexpr auto buffer =
49 NameBuffer<kTypenameSize>::FromCString(kTypenameStart);
54#define CPPGC_SUPPORTS_COMPILE_TIME_TYPENAME 0
78#if CPPGC_SUPPORTS_COMPILE_TIME_TYPENAME
80#elif CPPGC_SUPPORTS_OBJECT_NAMES
83 return std::is_base_of<NameProvider, T>::value;
89 return GetNameFor(
static_cast<const T*
>(obj), name_retrieval_mode);
100 static HeapObjectName GetNameFor(
105#if CPPGC_SUPPORTS_COMPILE_TIME_TYPENAME
106 return {GetTypename<T>(),
false};
107#elif CPPGC_SUPPORTS_OBJECT_NAMES
109#if defined(V8_CC_GNU)
110#define PRETTY_FUNCTION_VALUE __PRETTY_FUNCTION__
111#elif defined(V8_CC_MSVC)
112#define PRETTY_FUNCTION_VALUE __FUNCSIG__
114#define PRETTY_FUNCTION_VALUE nullptr
117 static const HeapObjectName leaky_name =
121#undef PRETTY_FUNCTION_VALUE
139#undef CPPGC_SUPPORTS_COMPILE_TIME_TYPENAME
Definition: name-provider.h:26
static constexpr const char kHiddenName[]
Definition: name-provider.h:31
virtual const char * GetHumanReadableName() const =0
Definition: name-trait.h:67
static HeapObjectName GetNameFromTypeSignature(const char *)
Definition: name-trait.h:75
static constexpr bool HasNonHiddenName()
Definition: name-trait.h:77
static HeapObjectName GetName(const void *obj, HeapObjectNameForUnnamedObject name_retrieval_mode)
Definition: name-trait.h:87
HeapObjectName(*)(const void *, HeapObjectNameForUnnamedObject) NameCallback
Definition: name-trait.h:134
HeapObjectNameForUnnamedObject
Definition: name-trait.h:62
@ kUseClassNameIfSupported
Definition: allocation.h:38
Definition: name-trait.h:57
const char * value
Definition: name-trait.h:58
bool name_was_hidden
Definition: name-trait.h:59
#define V8_EXPORT
Definition: v8config.h:793