Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-04-01 08:24:09

0001 // Copyright 2020 the V8 project authors. All rights reserved.
0002 // Use of this source code is governed by a BSD-style license that can be
0003 // found in the LICENSE file.
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 // Use CPPGC_STACK_ALLOCATED if the object is only stack allocated.
0022 // Add the CPPGC_STACK_ALLOCATED_IGNORE annotation on a case-by-case basis when
0023 // enforcement of CPPGC_STACK_ALLOCATED should be suppressed.
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  // !defined(__clang__)
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  // !defined(__clang__)
0049 
0050 template <typename T>
0051 concept IsStackAllocatedType =
0052     requires { typename T::IsStackAllocatedTypeMarker; };
0053 
0054 }  // namespace cppgc
0055 
0056 #endif  // INCLUDE_CPPGC_MACROS_H_