File indexing completed on 2026-04-01 08:24:09
0001
0002
0003
0004
0005 #ifndef INCLUDE_CPPGC_MACROS_H_
0006 #define INCLUDE_CPPGC_MACROS_H_
0007
0008 #include <cstddef>
0009
0010 #include "cppgc/internal/compiler-specific.h"
0011
0012 namespace cppgc {
0013
0014 #define CPPGC_DISALLOW_NEW() \
0015 public: \
0016 using IsDisallowNewMarker CPPGC_UNUSED = int; \
0017 void* operator new(size_t, void* location) { return location; } \
0018 void* operator new(size_t) = delete; \
0019 static_assert(true, "Force semicolon.")
0020
0021
0022
0023
0024 #if defined(__clang__)
0025
0026 #define CPPGC_STACK_ALLOCATED() \
0027 public: \
0028 using IsStackAllocatedTypeMarker CPPGC_UNUSED = int; \
0029 \
0030 private: \
0031 void* operator new(size_t) = delete; \
0032 void* operator new(size_t, void*) = delete; \
0033 static_assert(true, "Force semicolon.")
0034
0035 #define CPPGC_STACK_ALLOCATED_IGNORE(bug_or_reason) \
0036 __attribute__((annotate("stack_allocated_ignore")))
0037
0038 #define CPPGC_PLUGIN_IGNORE(bug_or_reason) \
0039 __attribute__((annotate("blink_gc_plugin_ignore"), \
0040 annotate("stack_allocated_ignore")))
0041
0042 #else
0043
0044 #define CPPGC_STACK_ALLOCATED() static_assert(true, "Force semicolon.")
0045 #define CPPGC_STACK_ALLOCATED_IGNORE(bug_or_reason)
0046 #define CPPGC_PLUGIN_IGNORE(bug_or_reason)
0047
0048 #endif
0049
0050 template <typename T>
0051 concept IsStackAllocatedType =
0052 requires { typename T::IsStackAllocatedTypeMarker; };
0053
0054 }
0055
0056 #endif