clang 24.0.0git
RecordLayoutUtils.h
Go to the documentation of this file.
1//===--- RecordLayoutUtils.h - Shared record layout queries -----*- 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 file holds the AST queries about record layout that both classic
10// CodeGen and CIR CodeGen need while lowering a record to its target type.
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef LLVM_CLANG_CODEGENUTILS_RECORDLAYOUTUTILS_H
15#define LLVM_CLANG_CODEGENUTILS_RECORDLAYOUTUTILS_H
16
18
19namespace clang::CodeGenUtils {
20
21/// Recursively searches all of the bases of \p Decl to find out whether
22/// \p Query is not the primary vbase of some base class.
23bool hasOwnStorage(const ASTContext &Ctx, const CXXRecordDecl *Decl,
24 const CXXRecordDecl *Query);
25
26/// The Microsoft bitfield layout rule allocates discrete storage units of the
27/// field's formal type and only combines adjacent fields of the same formal
28/// type. We want to emit a layout with these discrete storage units instead
29/// of combining them into a continuous run.
30bool isDiscreteBitFieldABI(const ASTContext &Ctx, const RecordDecl *RD);
31
32/// Return true iff the field is "empty", that is, either a zero-width
33/// bit-field or an \ref isEmptyRecordForLayout.
34bool isEmptyFieldForLayout(const ASTContext &Ctx, const FieldDecl *FD);
35
36/// Return true iff a structure contains only empty base classes (per \ref
37/// isEmptyRecordForLayout) and fields (per \ref isEmptyFieldForLayout). Note,
38/// C++ record fields are considered empty if the [[no_unique_address]]
39/// attribute would have made them empty, so this is not the same as \ref
40/// isEmptyRecord.
41bool isEmptyRecordForLayout(const ASTContext &Ctx, QualType T);
42
43/// The Itanium base layout rule allows virtual bases to overlap other bases,
44/// which complicates layout in specific ways.
45///
46/// Note specifically that the ms_struct attribute doesn't change this.
47bool isOverlappingVBaseABI(const ASTContext &Ctx);
48
49} // namespace clang::CodeGenUtils
50
51#endif // LLVM_CLANG_CODEGENUTILS_RECORDLAYOUTUTILS_H
Defines the clang::ASTContext interface.
bool isDiscreteBitFieldABI(const ASTContext &Ctx, const RecordDecl *RD)
The Microsoft bitfield layout rule allocates discrete storage units of the field's formal type and on...
bool hasOwnStorage(const ASTContext &Ctx, const CXXRecordDecl *Decl, const CXXRecordDecl *Query)
Recursively searches all of the bases of Decl to find out whether Query is not the primary vbase of s...
bool isOverlappingVBaseABI(const ASTContext &Ctx)
The Itanium base layout rule allows virtual bases to overlap other bases, which complicates layout in...
bool isEmptyFieldForLayout(const ASTContext &Ctx, const FieldDecl *FD)
Return true iff the field is "empty", that is, either a zero-width bit-field or an isEmptyRecordForLa...
bool isEmptyRecordForLayout(const ASTContext &Ctx, QualType T)
Return true iff a structure contains only empty base classes (per isEmptyRecordForLayout) and fields ...
const FunctionProtoType * T