clang 20.0.0git
CGBlocks.h
Go to the documentation of this file.
1//===-- CGBlocks.h - state for LLVM CodeGen for blocks ----------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// This is the internal state used for llvm translation for block literals.
10//
11//===----------------------------------------------------------------------===//
12
13#ifndef LLVM_CLANG_LIB_CODEGEN_CGBLOCKS_H
14#define LLVM_CLANG_LIB_CODEGEN_CGBLOCKS_H
15
16#include "CGBuilder.h"
17#include "CGCall.h"
18#include "CGValue.h"
19#include "CodeGenFunction.h"
20#include "CodeGenTypes.h"
21#include "clang/AST/CharUnits.h"
22#include "clang/AST/Expr.h"
23#include "clang/AST/ExprCXX.h"
24#include "clang/AST/ExprObjC.h"
25#include "clang/AST/Type.h"
27
28namespace llvm {
29class Value;
30}
31
32namespace clang {
33namespace CodeGen {
34
35class CGBlockInfo;
36
37// Flags stored in __block variables.
39 BLOCK_BYREF_HAS_COPY_DISPOSE = (1 << 25), // compiler
40 BLOCK_BYREF_LAYOUT_MASK = (0xF << 28), // compiler
46};
47
49 BLOCK_IS_NOESCAPE = (1 << 23),
51 BLOCK_HAS_CXX_OBJ = (1 << 26),
52 BLOCK_IS_GLOBAL = (1 << 28),
53 BLOCK_USE_STRET = (1 << 29),
55 BLOCK_HAS_EXTENDED_LAYOUT = (1u << 31)
56};
58 uint32_t flags;
59
60public:
61 BlockFlags(uint32_t flags) : flags(flags) {}
62 BlockFlags() : flags(0) {}
63 BlockFlags(BlockLiteralFlags flag) : flags(flag) {}
64 BlockFlags(BlockByrefFlags flag) : flags(flag) {}
65
66 uint32_t getBitMask() const { return flags; }
67 bool empty() const { return flags == 0; }
68
70 return BlockFlags(l.flags | r.flags);
71 }
73 l.flags |= r.flags;
74 return l;
75 }
76 friend bool operator&(BlockFlags l, BlockFlags r) {
77 return (l.flags & r.flags);
78 }
80 return (flags == r.flags);
81 }
82};
84 return BlockFlags(l) | BlockFlags(r);
85}
86
88 BLOCK_FIELD_IS_OBJECT = 0x03, /* id, NSObject, __attribute__((NSObject)),
89 block, ... */
90 BLOCK_FIELD_IS_BLOCK = 0x07, /* a block variable */
91
92 BLOCK_FIELD_IS_BYREF = 0x08, /* the on stack structure holding the __block
93 variable */
94 BLOCK_FIELD_IS_WEAK = 0x10, /* declared __weak, only used in byref copy
95 helpers */
96 BLOCK_FIELD_IS_ARC = 0x40, /* field has ARC-specific semantics */
97 BLOCK_BYREF_CALLER = 128, /* called from __block (byref) copy/dispose
98 support routines */
101
102class