LLVM 23.0.0git
Types.cpp
Go to the documentation of this file.
1//===----------------------------------------------------------------------===//
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#include "llvm/ABI/Types.h"
11
12using namespace llvm;
13using namespace llvm::abi;
14
15bool RecordType::isEmpty() const {
18 return false;
19
20 for (const FieldInfo &Base : getBaseClasses()) {
21 const auto *BaseRT = dyn_cast<RecordType>(Base.FieldType);
22 if (!BaseRT || !BaseRT->isEmpty())
23 return false;
24 }
25
26 for (const FieldInfo &FI : getFields()) {
27 if (!FI.isEmpty())
28 return false;
29 }
30 return true;
31}
32
33bool FieldInfo::isEmpty() const {
35 return true;
36 if (IsBitField && BitFieldWidth == 0)
37 return true;
38
39 const Type *Ty = FieldType;
40 while (const auto *AT = dyn_cast<ArrayType>(Ty)) {
41 if (AT->getNumElements() != 1)
42 break;
43 Ty = AT->getElementType();
44 }
45
46 if (const auto *RT = dyn_cast<RecordType>(Ty))
47 return RT->isEmpty();
48
49 return Ty->isZeroSize();
50}
bool isPolymorphic() const
Definition Types.h:288
ArrayRef< FieldInfo > getBaseClasses() const
Definition Types.h:306
ArrayRef< FieldInfo > getFields() const
Definition Types.h:305
uint32_t getNumVirtualBaseClasses() const
Definition Types.h:299
bool hasFlexibleArrayMember() const
Definition Types.h:294
Represents the ABI-specific view of a type in LLVM.
Definition Types.h:43
This file defines the type system for the LLVMABI library, which mirrors ABI-relevant aspects of fron...
This is an optimization pass for GlobalISel generic memory operations.
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
Definition Casting.h:643
const Type * FieldType
Definition Types.h:234
uint64_t BitFieldWidth
Definition Types.h:236
bool isEmpty() const
Definition Types.cpp:33