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/// The Microsoft bitfield layout rule allocates discrete storage units of the
22/// field's formal type and only combines adjacent fields of the same formal
23/// type. We want to emit a layout with these discrete storage units instead
24/// of combining them into a continuous run.
25bool isDiscreteBitFieldABI(const ASTContext &Ctx, const RecordDecl *RD);
26
27/// Return true iff the field is "empty", that is, either a zero-width
28/// bit-field or an \ref isEmptyRecordForLayout.
29bool isEmptyFieldForLayout(const ASTContext &Ctx, const FieldDecl *FD);
30
31/// Return true iff a structure contains only empty base classes (per \ref
32/// isEmptyRecordForLayout) and fields (per \ref isEmptyFieldForLayout). Note,
33/// C++ record fields are considered empty if the [[no_unique_address]]
34/// attribute would have made them empty, so this is not the same as \ref
35/// isEmptyRecord.
36bool isEmptyRecordForLayout(const ASTContext &Ctx, QualType T);
37
38/// The Itanium base layout rule allows virtual bases to overlap other bases,
39/// which complicates layout in specific ways.
40///
41/// Note specifically that the ms_struct attribute doesn't change this.
42bool isOverlappingVBaseABI(const ASTContext &Ctx);
43
44} // namespace clang::CodeGenUtils
45
46#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 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