11cb0ef41Sopenharmony_ci// Copyright 2020 the V8 project authors. All rights reserved. 21cb0ef41Sopenharmony_ci// Use of this source code is governed by a BSD-style license that can be 31cb0ef41Sopenharmony_ci// found in the LICENSE file. 41cb0ef41Sopenharmony_ci 51cb0ef41Sopenharmony_ci#ifndef INCLUDE_CPPGC_MACROS_H_ 61cb0ef41Sopenharmony_ci#define INCLUDE_CPPGC_MACROS_H_ 71cb0ef41Sopenharmony_ci 81cb0ef41Sopenharmony_ci#include <cstddef> 91cb0ef41Sopenharmony_ci 101cb0ef41Sopenharmony_ci#include "cppgc/internal/compiler-specific.h" 111cb0ef41Sopenharmony_ci 121cb0ef41Sopenharmony_cinamespace cppgc { 131cb0ef41Sopenharmony_ci 141cb0ef41Sopenharmony_ci// Use CPPGC_STACK_ALLOCATED if the object is only stack allocated. 151cb0ef41Sopenharmony_ci// Add the CPPGC_STACK_ALLOCATED_IGNORE annotation on a case-by-case basis when 161cb0ef41Sopenharmony_ci// enforcement of CPPGC_STACK_ALLOCATED should be suppressed. 171cb0ef41Sopenharmony_ci#if defined(__clang__) 181cb0ef41Sopenharmony_ci#define CPPGC_STACK_ALLOCATED() \ 191cb0ef41Sopenharmony_ci public: \ 201cb0ef41Sopenharmony_ci using IsStackAllocatedTypeMarker CPPGC_UNUSED = int; \ 211cb0ef41Sopenharmony_ci \ 221cb0ef41Sopenharmony_ci private: \ 231cb0ef41Sopenharmony_ci void* operator new(size_t) = delete; \ 241cb0ef41Sopenharmony_ci void* operator new(size_t, void*) = delete; \ 251cb0ef41Sopenharmony_ci static_assert(true, "Force semicolon.") 261cb0ef41Sopenharmony_ci#define CPPGC_STACK_ALLOCATED_IGNORE(bug_or_reason) \ 271cb0ef41Sopenharmony_ci __attribute__((annotate("stack_allocated_ignore"))) 281cb0ef41Sopenharmony_ci#else // !defined(__clang__) 291cb0ef41Sopenharmony_ci#define CPPGC_STACK_ALLOCATED() static_assert(true, "Force semicolon.") 301cb0ef41Sopenharmony_ci#define CPPGC_STACK_ALLOCATED_IGNORE(bug_or_reason) 311cb0ef41Sopenharmony_ci#endif // !defined(__clang__) 321cb0ef41Sopenharmony_ci 331cb0ef41Sopenharmony_ci} // namespace cppgc 341cb0ef41Sopenharmony_ci 351cb0ef41Sopenharmony_ci#endif // INCLUDE_CPPGC_MACROS_H_ 36