clang 23.0.0git
QualTypeMapper.cpp
Go to the documentation of this file.
1//==---- QualTypeMapper.cpp - Maps Clang QualType to LLVMABI Types ---------==//
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/// \file
10/// Maps Clang QualType instances to corresponding LLVM ABI type
11/// representations. This mapper translates high-level type information from the
12/// AST into low-level ABI-specific types that encode size, alignment, and
13/// layout details required for code generation and cross-language
14/// interoperability.
15///
16//===----------------------------------------------------------------------===//
17#include "QualTypeMapper.h"
19#include "clang/AST/ASTFwd.h"
20#include "clang/AST/Attr.h"
21#include "clang/AST/Decl.h"
22#include "clang/AST/DeclCXX.h"
24#include "clang/AST/Type.h"
26#include "clang/Basic/LLVM.h"
28#include "llvm/ABI/Types.h"
29#include "llvm/Support/Alignment.h"
30#include "llvm/Support/ErrorHandling.h"
31#include "llvm/Support/TypeSize.h"
32#include <cstdint>
33
34namespace clang {
35namespace CodeGen {
36
37/// Main entry point for converting Clang QualType to LLVM ABI Type.
38/// This method performs type canonicalization, caching, and dispatches
39/// to specialized conversion methods based on the type kind.
40///
41/// \param QT The Clang QualType to convert
42/// \return Corresponding LLVM ABI Type representation
43const llvm::abi::Type *QualTypeMapper::convertType(QualType QT) {
44 // Canonicalize type and strip qualifiers
45 // This ensures consistent type representation across different contexts
46 //
47 // TODO: AttributedType is NeverCanonical, so aligned typedef attributes
48 // for instance, __attribute__((aligned(N))) are lost here. Capture the
49 // effective alignment from the original QT and thread it through
50 // convertTypeImpl.
52
53 // Results are cached since type conversion may be expensive.
54 auto It = TypeCache.find(QT);
55 if (It != TypeCache.end())
56 return It->second;
57
58 const llvm::abi::Type *Result = convertTypeImpl(QT);
59 assert(Result && "convertTypeImpl returned nullptr");
60 TypeCache[QT] = Result;
61 return Result;
62}
63
64/// Dispatches to specialized conversion methods based on the type kind.
65const llvm::abi::Type *QualTypeMapper::convertTypeImpl(QualType QT) {
66 switch (QT->getTypeClass()) {
67 // Non-canonical and dependent types should have been stripped by
68 // getCanonicalType() above or cannot appear during code generation.
69#define TYPE(Class, Base)
70#define ABSTRACT_TYPE(Class, Base)
71#define NON_CANONICAL_TYPE(Class, Base) case Type::Class:
72#define DEPENDENT_TYPE(Class, Base) case Type::Class:
73#define NON_CANONICAL_UNLESS_DEPENDENT_TYPE(Class, Base) case Type::Class:
74#include "clang/AST/TypeNodes.inc"
75 llvm::reportFatalInternalError(
76 "Non-canonical or dependent types should not reach ABI lowering");
77
78 case Type::Builtin:
79 return convertBuiltinType(cast<BuiltinType>(QT));
80 case Type::Pointer:
81 return createPointerTypeForPointee(cast<PointerType>(QT)->getPointeeType());
82 case Type::LValueReference:
83 case Type::RValueReference:
84 return createPointerTypeForPointee(
86 case Type::ConstantArray:
87 case Type::ArrayParameter:
88 case Type::IncompleteArray:
89 case Type::VariableArray:
90 return convertArrayType(cast<ArrayType>(QT));
91 case Type::Vector:
92 case Type::ExtVector:
93 return convertVectorType(cast<VectorType>(QT));
94 case Type::Record:
95 return convertRecordType(cast<RecordType>(QT));
96 case Type::Enum:
97 return convertEnumType(cast<EnumType>(QT));
98 case Type::Complex:
99 return convertComplexType(cast<ComplexType>(QT));
100 case Type::Atomic:
101 return convertType(cast<AtomicType>(QT)->getValueType());
102 case Type::BlockPointer:
103 case Type::Pipe:
104 return createPointerTypeForPointee(ASTCtx.VoidPtrTy);
105 case Type::ConstantMatrix: {
106 const auto *MT = cast<ConstantMatrixType>(QT);
107 return Builder.getArrayType(convertType(MT->getElementType()),
108 MT->getNumRows() * MT->getNumColumns(),
109 ASTCtx.getTypeSize(QT), /*IsMatrixType=*/true);
110 }
111 case Type::MemberPointer:
112 return convertMemberPointerType(cast<MemberPointerType>(QT));
113 case Type::BitInt: {
114 const auto *BIT = cast<BitIntType>(QT);
115 return Builder.getIntegerType(BIT->getNumBits(), getTypeAlign(QT),
116 /*Signed=*/BIT->isSigned(),
117 /*IsBitInt=*/true);
118 }
119 case Type::ObjCObject:
120 case Type::ObjCInterface:
121 case Type::ObjCObjectPointer:
122 // Objective-C objects are represented as pointers in the ABI.
123 return Builder.getPointerType(
125 llvm::Align(
128 case Type::OverflowBehavior:
130 case Type::Auto:
131 case Type::DeducedTemplateSpecialization:
132 case Type::FunctionProto:
133 case Type::FunctionNoProto:
134 case Type::HLSLAttributedResource:
135 case Type::HLSLInlineSpirv:
136 llvm::reportFatalInternalError("Type not supported in ABI lowering");
137 }
138 llvm_unreachable("unhandled type class in convertTypeImpl");
139}
140
141/// Converts C/C++ builtin types to LLVM ABI types.
142/// This handles all fundamental scalar types including integers, floats,
143/// and special types like void and bool.
144const llvm::abi::Type *
145QualTypeMapper::convertBuiltinType(const BuiltinType *BT) {
146 QualType QT(BT, 0);
147
148 switch (BT->getKind()) {
149 case BuiltinType::Void:
150 return Builder.getVoidType();
151
152 case BuiltinType::NullPtr:
153 return createPointerTypeForPointee(QT);
154
155 case BuiltinType::Bool:
156 return Builder.getIntegerType(1, getTypeAlign(QT), /*Signed=*/false,
157 /*IsBitInt=*/false);
158
159 case BuiltinType::Char_S:
160 case BuiltinType::Char_U:
161 case BuiltinType::SChar:
162 case BuiltinType::UChar:
163 case BuiltinType::WChar_S:
164 case BuiltinType::WChar_U:
165 case BuiltinType::Char8:
166 case BuiltinType::Char16:
167 case BuiltinType::Char32:
168 case BuiltinType::Short:
169 case BuiltinType::UShort:
170 case BuiltinType::Int:
171 case BuiltinType::UInt:
172 case BuiltinType::Long:
173 case BuiltinType::ULong:
174 case BuiltinType::LongLong:
175 case BuiltinType::ULongLong:
176 case BuiltinType::Int128:
177 case BuiltinType::UInt128:
178 return Builder.getIntegerType(ASTCtx.getTypeSize(QT), getTypeAlign(QT),
179 /*Signed=*/BT->isSignedInteger(),
180 /*IsBitInt=*/false);
181
182 case BuiltinType::Half:
183 case BuiltinType::Float16:
184 case BuiltinType::BFloat16:
185 case BuiltinType::Float:
186 case BuiltinType::Double:
187 case BuiltinType::LongDouble:
188 case BuiltinType::Float128:
189 return Builder.getFloatType(ASTCtx.getFloatTypeSemantics(QT),
190 getTypeAlign(QT));
191
192 // TODO: IBM 128-bit extended double
193 case BuiltinType::Ibm128:
194 llvm::reportFatalInternalError(
195 "IBM128 is not yet supported in the ABI lowering libary");
196
197 // TODO: Fixed-point types
198 case BuiltinType::ShortAccum:
199 case BuiltinType::Accum:
200 case BuiltinType::LongAccum:
201 case BuiltinType::UShortAccum:
202 case BuiltinType::UAccum:
203 case BuiltinType::ULongAccum:
204 case BuiltinType::ShortFract:
205 case BuiltinType::Fract:
206 case BuiltinType::LongFract:
207 case BuiltinType::UShortFract:
208 case BuiltinType::UFract:
209 case BuiltinType::ULongFract:
210 case BuiltinType::SatShortAccum:
211 case BuiltinType::SatAccum:
212 case BuiltinType::SatLongAccum:
213 case BuiltinType::SatUShortAccum:
214 case BuiltinType::SatUAccum:
215 case BuiltinType::SatULongAccum:
216 case BuiltinType::SatShortFract:
217 case BuiltinType::SatFract:
218 case BuiltinType::SatLongFract:
219 case BuiltinType::SatUShortFract:
220 case BuiltinType::SatUFract:
221 case BuiltinType::SatULongFract:
222 llvm::reportFatalInternalError(
223 "Fixed Point types not yet implemented in the ABI lowering library");
224
225 // OpenCL image types are represented as opaque pointers.
226#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
227 case BuiltinType::Id:
228#include "clang/Basic/OpenCLImageTypes.def"
229 // OpenCL extension types are represented as opaque pointers.
230#define EXT_OPAQUE_TYPE(ExtType, Id, Ext) case BuiltinType::Id:
231#include "clang/Basic/OpenCLExtensionTypes.def"
232 case BuiltinType::OCLSampler:
233 case BuiltinType::OCLEvent:
234 case BuiltinType::OCLClkEvent:
235 case BuiltinType::OCLQueue:
236 case BuiltinType::OCLReserveID:
237 return createPointerTypeForPointee(QT);
238
239 // Objective-C builtin types are represented as opaque pointers.
240 case BuiltinType::ObjCId:
241 case BuiltinType::ObjCClass:
242 case BuiltinType::ObjCSel:
243 return createPointerTypeForPointee(QT);
244
245 // Target-specific vector/matrix types — not yet implemented.
246#define SVE_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
247#include "clang/Basic/AArch64ACLETypes.def"
248 llvm::reportFatalInternalError(
249 "AArch64 SVE types not yet supported in ABI lowering library");
250#define PPC_VECTOR_TYPE(Name, Id, Size) case BuiltinType::Id:
251#include "clang/Basic/PPCTypes.def"
252 llvm::reportFatalInternalError(
253 "PPC MMA types not yet supported in ABI lowering library");
254#define RVV_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
255#include "clang/Basic/RISCVVTypes.def"
256 llvm::reportFatalInternalError(
257 "RISC-V vector types not yet supported in ABI lowering library");
258#define WASM_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
259#include "clang/Basic/WebAssemblyReferenceTypes.def"
260 llvm::reportFatalInternalError("WebAssembly reference types not yet "
261 "supported in ABI lowering library");
262#define AMDGPU_TYPE(Name, Id, SingletonId, Width, Align) case BuiltinType::Id:
263#include "clang/Basic/AMDGPUTypes.def"
264 llvm::reportFatalInternalError(
265 "AMDGPU types not yet supported in ABI lowering library");
266#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
267#include "clang/Basic/HLSLIntangibleTypes.def"
268 llvm::reportFatalInternalError(
269 "HLSL intangible types not yet Supported in ABI lowering library");
270
271 // Placeholder types should never reach ABI lowering.
272#define PLACEHOLDER_TYPE(Id, SingletonId) case BuiltinType::Id:
273#define BUILTIN_TYPE(Id, SingletonId)
274#include "clang/AST/BuiltinTypes.def"
275 llvm::reportFatalInternalError(
276 "Placeholder type should not reach ABI lowering");
277
278 case BuiltinType::Dependent:
279 llvm::reportFatalInternalError(
280 "Dependent builtin type should not reach ABI lowering");
281 }
282 llvm_unreachable("unhandled builtin type kind in convertBuiltinType");
283}
284
285/// Converts array types to LLVM ABI array representations.
286/// Handles different array kinds: constant arrays, incomplete arrays,
287/// and variable-length arrays.
288///
289/// \param AT The ArrayType to convert
290/// \return LLVM ABI ArrayType or PointerType
291const llvm::abi::Type *
292QualTypeMapper::convertArrayType(const clang::ArrayType *AT) {
293 const llvm::abi::Type *ElementType = convertType(AT->getElementType());
294 uint64_t Size = ASTCtx.getTypeSize(AT);
295
296 if (const auto *CAT = dyn_cast<ConstantArrayType>(AT)) {
297 auto NumElements = CAT->getZExtSize();
298 return Builder.getArrayType(ElementType, NumElements, Size);
299 }
301 return Builder.getArrayType(ElementType, 0, 0);
302 if (const auto *VAT = dyn_cast<VariableArrayType>(AT))
303 return createPointerTypeForPointee(VAT->getPointeeType());
304 llvm::reportFatalInternalError(
305 "unexpected array type in ABI lowering (dependent array types should be "
306 "resolved before reaching this point)");
307}
308
309const llvm::abi::Type *QualTypeMapper::convertVectorType(const VectorType *VT) {
310 const llvm::abi::Type *ElementType = convertType(VT->getElementType());
311 QualType VectorQualType(VT, 0);
312
313 unsigned NElems = VT->getNumElements();
314 llvm::ElementCount NumElements = llvm::ElementCount::getFixed(NElems);
315 llvm::Align VectorAlign = getTypeAlign(VectorQualType);
316
317 return Builder.getVectorType(ElementType, NumElements, VectorAlign);
318}
319
320/// Converts complex types to LLVM ABI complex representations.
321/// Complex types consist of two components of the element type
322/// (real and imaginary parts).
323///
324/// \param CT The ComplexType to convert
325/// \return LLVM ABI ComplexType with element type and alignment
326const llvm::abi::Type *
327QualTypeMapper::convertComplexType(const ComplexType *CT) {
328 const llvm::abi::Type *ElementType = convertType(CT->getElementType());
329 llvm::Align ComplexAlign = getTypeAlign(QualType(CT, 0));
330
331 return Builder.getComplexType(ElementType, ComplexAlign);
332}
333
334/// Converts member pointer types to LLVM ABI representations.
335/// Member pointers have different layouts depending on whether they
336/// point to functions or data members.
337///
338/// \param MPT The MemberPointerType to convert
339/// \return LLVM ABI MemberPointerType
340const llvm::abi::Type *
341QualTypeMapper::convertMemberPointerType(const clang::MemberPointerType *MPT) {
342 QualType QT(MPT, 0);
343 uint64_t Size = ASTCtx.getTypeSize(QT);
344 llvm::Align Align = getTypeAlign(QT);
345
346 bool IsFunctionPointer = MPT->isMemberFunctionPointerType();
347
348 return Builder.getMemberPointerType(IsFunctionPointer, Size, Align);
349}
350
351/// Converts record types (struct/class/union) to LLVM ABI representations.
352/// This is the main dispatch method that handles different record kinds
353/// and delegates to specialized converters.
354///
355/// \param RT The RecordType to convert
356/// \return LLVM ABI RecordType
357const llvm::abi::Type *QualTypeMapper::convertRecordType(const RecordType *RT) {
358 const RecordDecl *RD = RT->getDecl()->getDefinition();
359 if (!RD)
360 return Builder.getRecordType({}, llvm::TypeSize::getFixed(0),
361 llvm::Align(1));
362
363 if (RD->isUnion())
364 return convertUnionType(RD);
365
366 // Handle C++ classes with base classes
367 auto *CXXRd = dyn_cast<CXXRecordDecl>(RD);
368 if (CXXRd && (CXXRd->getNumBases() > 0 || CXXRd->getNumVBases() > 0))
369 return convertCXXRecordType(CXXRd);
370 return convertStructType(RD);
371}
372
373/// Converts C++ classes with inheritance to LLVM ABI struct representations.
374/// This method handles the complex layout of C++ objects including:
375/// - Virtual table pointers for polymorphic classes
376/// - Base class subobjects (both direct and virtual bases)
377/// - Member field layout with proper offsets
378///
379/// \param RD The C++ record declaration
380/// \return LLVM ABI RecordType representing the complete object layout
381const llvm::abi::RecordType *
382QualTypeMapper::convertCXXRecordType(const CXXRecordDecl *RD) {
383 const ASTRecordLayout &Layout = ASTCtx.getASTRecordLayout(RD);
384 SmallVector<llvm::abi::FieldInfo, 16> Fields;
385 SmallVector<llvm::abi::FieldInfo, 8> BaseClasses;
386 SmallVector<llvm::abi::FieldInfo, 8> VirtualBaseClasses;
387
388 // Add vtable pointer for polymorphic classes
389 if (RD->isPolymorphic()) {
390 const llvm::abi::Type *VtablePointer =
391 createPointerTypeForPointee(ASTCtx.VoidPtrTy);
392 Fields.emplace_back(VtablePointer, 0);
393 }
394
395 for (const auto &Base : RD->bases()) {
396 if (Base.isVirtual())
397 continue;
398
399 const RecordType *BaseRT = Base.getType()->castAs<RecordType>();
400 const llvm::abi::Type *BaseType = convertType(Base.getType());
401 uint64_t BaseOffset =
402 Layout.getBaseClassOffset(BaseRT->getAsCXXRecordDecl()).getQuantity() *
403 8;
404
405 BaseClasses.emplace_back(BaseType, BaseOffset);
406 }
407
408 for (const auto &VBase : RD->vbases()) {
409 const RecordType *VBaseRT = VBase.getType()->castAs<RecordType>();
410 const llvm::abi::Type *VBaseType = convertType(VBase.getType());
411 uint64_t VBaseOffset =
412 Layout.getVBaseClassOffset(VBaseRT->getAsCXXRecordDecl())
413 .getQuantity() *
414 8;
415
416 VirtualBaseClasses.emplace_back(VBaseType, VBaseOffset);
417 }
418
419 computeFieldInfo(RD, Fields, Layout);
420
421 llvm::sort(Fields,
422 [](const llvm::abi::FieldInfo &A, const llvm::abi::FieldInfo &B) {
423 return A.OffsetInBits < B.OffsetInBits;
424 });
425
426 llvm::TypeSize Size =
427 llvm::TypeSize::getFixed(Layout.getSize().getQuantity() * 8);
428 llvm::Align Alignment = llvm::Align(Layout.getAlignment().getQuantity());
429
430 llvm::abi::RecordFlags RecFlags = llvm::abi::RecordFlags::IsCXXRecord;
431 if (RD->isPolymorphic())
432 RecFlags |= llvm::abi::RecordFlags::IsPolymorphic;
433 if (RD->canPassInRegisters())
434 RecFlags |= llvm::abi::RecordFlags::CanPassInRegisters;
435 if (RD->hasFlexibleArrayMember())
436 RecFlags |= llvm::abi::RecordFlags::HasFlexibleArrayMember;
437
438 return Builder.getRecordType(Fields, Size, Alignment,
439 llvm::abi::StructPacking::Default, BaseClasses,
440 VirtualBaseClasses, RecFlags);
441}
442
443/// Converts enumeration types to their underlying integer representations.
444/// This method handles various enum states and falls back to safe defaults
445/// when enum information is incomplete or invalid.
446///
447/// \param ET The EnumType to convert
448/// \return LLVM ABI IntegerType representing the enum's underlying type
449const llvm::abi::Type *
450QualTypeMapper::convertEnumType(const clang::EnumType *ET) {
451 const EnumDecl *ED = ET->getDecl();
452 QualType UnderlyingType = ED->getIntegerType();
453
454 if (UnderlyingType.isNull())
455 UnderlyingType = ASTCtx.IntTy;
456
457 return convertType(UnderlyingType);
458}
459
460/// Converts plain C structs and C++ classes without inheritance.
461/// This handles the simpler case where we only need to layout member fields
462/// without considering base classes or virtual functions.
463///
464/// \param RD The RecordDecl to convert
465/// \return LLVM ABI RecordType
466const llvm::abi::RecordType *
467QualTypeMapper::convertStructType(const clang::RecordDecl *RD) {
468 const ASTRecordLayout &Layout = ASTCtx.getASTRecordLayout(RD);
469
470 bool IsCXXRecord = isa<CXXRecordDecl>(RD);
471 SmallVector<llvm::abi::FieldInfo, 16> Fields;
472 computeFieldInfo(RD, Fields, Layout);
473
474 llvm::TypeSize Size =
475 llvm::TypeSize::getFixed(Layout.getSize().getQuantity() * 8);
476 llvm::Align Alignment = llvm::Align(Layout.getAlignment().getQuantity());
477
478 llvm::abi::RecordFlags RecFlags = llvm::abi::RecordFlags::None;
479 if (IsCXXRecord)
480 RecFlags |= llvm::abi::RecordFlags::IsCXXRecord;
481 if (RD->canPassInRegisters())
482 RecFlags |= llvm::abi::RecordFlags::CanPassInRegisters;
483 if (RD->hasFlexibleArrayMember())
484 RecFlags |= llvm::abi::RecordFlags::HasFlexibleArrayMember;
485
486 return Builder.getRecordType(Fields, Size, Alignment,
487 llvm::abi::StructPacking::Default, {}, {},
488 RecFlags);
489}
490
491/// Converts C union types where all fields occupy the same memory location.
492/// The union size is determined by its largest member, and all fields
493/// start at offset 0.
494///
495/// \param RD The RecordDecl representing the union
496/// \return LLVM ABI UnionType
497const llvm::abi::RecordType *
498QualTypeMapper::convertUnionType(const clang::RecordDecl *RD) {
499 const ASTRecordLayout &Layout = ASTCtx.getASTRecordLayout(RD);
500
501 SmallVector<llvm::abi::FieldInfo, 16> AllFields;
502 computeFieldInfo(RD, AllFields, Layout);
503
504 llvm::TypeSize Size =
505 llvm::TypeSize::getFixed(Layout.getSize().getQuantity() * 8);
506 llvm::Align Alignment = llvm::Align(Layout.getAlignment().getQuantity());
507
508 llvm::abi::RecordFlags RecFlags = llvm::abi::RecordFlags::None;
509 if (RD->hasAttr<TransparentUnionAttr>())
510 RecFlags |= llvm::abi::RecordFlags::IsTransparent;
511 if (RD->canPassInRegisters())
512 RecFlags |= llvm::abi::RecordFlags::CanPassInRegisters;
513 if (isa<CXXRecordDecl>(RD))
514 RecFlags |= llvm::abi::RecordFlags::IsCXXRecord;
515
516 return Builder.getUnionType(AllFields, Size, Alignment,
517 llvm::abi::StructPacking::Default, RecFlags);
518}
519
520llvm::Align QualTypeMapper::getTypeAlign(QualType QT) const {
521
522 return llvm::Align(ASTCtx.getTypeAlignInChars(QT).getQuantity());
523}
524
525const llvm::abi::Type *
526QualTypeMapper::createPointerTypeForPointee(QualType PointeeType) {
527 auto AddrSpace = PointeeType.getAddressSpace();
528 auto PointerSize = ASTCtx.getTargetInfo().getPointerWidth(AddrSpace);
529 llvm::Align Alignment =
530 llvm::Align(ASTCtx.getTargetInfo().getPointerAlign(AddrSpace));
531 // Function types without an explicit address space qualifier use the program
532 // address space, which may differ from the default data address space on
533 // targets like AMDGPU.
534 unsigned TargetAddrSpace =
535 PointeeType->isFunctionType() && !PointeeType.hasAddressSpace()
536 ? DL.getProgramAddressSpace()
537 : ASTCtx.getTargetInfo().getTargetAddressSpace(AddrSpace);
538 return Builder.getPointerType(PointerSize, llvm::Align(Alignment.value() / 8),
539 TargetAddrSpace);
540}
541
542/// Processes the fields of a record (struct/class/union) and populates
543/// the Fields vector with FieldInfo objects containing type, offset,
544/// and bitfield information.
545///
546/// \param RD The RecordDecl whose fields to process
547/// \param Fields Output vector to populate with field information
548/// \param Layout The AST record layout containing field offset information
549void QualTypeMapper::computeFieldInfo(
550 const RecordDecl *RD, SmallVectorImpl<llvm::abi::FieldInfo> &Fields,
551 const ASTRecordLayout &Layout) {
552 unsigned FieldIndex = 0;
553
554 for (const auto *FD : RD->fields()) {
555 const llvm::abi::Type *FieldType = convertType(FD->getType());
556 uint64_t OffsetInBits = Layout.getFieldOffset(FieldIndex);
557
558 bool IsBitField = FD->isBitField();
559 uint64_t BitFieldWidth = 0;
560 bool IsUnnamedBitField = false;
561
562 if (IsBitField) {
563 BitFieldWidth = FD->getBitWidthValue();
564 IsUnnamedBitField = FD->isUnnamedBitField();
565 }
566
567 Fields.emplace_back(FieldType, OffsetInBits, IsBitField, BitFieldWidth,
568 IsUnnamedBitField);
569 ++FieldIndex;
570 }
571}
572
573} // namespace CodeGen
574} // namespace clang
Defines the clang::ASTContext interface.
Forward declaration of all AST node types.
Provides definitions for the various language-specific address spaces.
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate....
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified.
Maps Clang QualType instances to corresponding LLVM ABI type representations.
static QualType getUnderlyingType(const SubRegion *R)
static QualType getPointeeType(const MemRegion *R)
C Language Family Type Representation.
CanQualType VoidPtrTy
uint64_t getTypeSize(QualType T) const
Return the size of the specified (complete) type T, in bits.
const TargetInfo & getTargetInfo() const
Definition ASTContext.h:916
QualType getElementType() const
Definition TypeBase.h:3742
const llvm::abi::Type * convertType(clang::QualType QT)
Main entry point for converting Clang QualType to LLVM ABI Type.
bool hasAttr() const
Definition DeclBase.h:577
A (possibly-)qualified type.
Definition TypeBase.h:937
LangAS getAddressSpace() const
Return the address space of this type.
Definition TypeBase.h:8514
QualType getCanonicalType() const
Definition TypeBase.h:8440
QualType getUnqualifiedType() const
Retrieve the unqualified variant of the given type, removing as little sugar as possible.
Definition TypeBase.h:8482
bool canPassInRegisters() const
Determine whether this class can be passed in registers.
Definition Decl.h:4464
bool hasFlexibleArrayMember() const
Definition Decl.h:4360
uint64_t getPointerWidth(LangAS AddrSpace) const
Return the width of pointers on this target, for the specified address space.
Definition TargetInfo.h:489
unsigned getTargetAddressSpace(LangAS AS) const
uint64_t getPointerAlign(LangAS AddrSpace) const
Definition TargetInfo.h:493
bool isMemberFunctionPointerType() const
Definition TypeBase.h:8710
TypeClass getTypeClass() const
Definition TypeBase.h:2391
Defines the clang::TargetInfo interface.
The JSON file list parser is used to communicate input to InstallAPI.
bool isa(CodeGen::Address addr)
Definition Address.h:330
@ Result
The result type of a method or function.
Definition TypeBase.h:905
U cast(CodeGen::Address addr)
Definition Address.h:327
unsigned long uint64_t