clang 22.0.0git
TargetInfo.cpp
Go to the documentation of this file.
1#include "TargetInfo.h"
2#include "ABIInfo.h"
3
4using namespace clang;
5using namespace clang::CIRGen;
6
8 QualType t) {
9 const auto *rd = t->getAsRecordDecl();
10 if (!rd)
11 return false;
12
13 // If this is a C++ record, check the bases first.
14 if (const CXXRecordDecl *cxxrd = dyn_cast<CXXRecordDecl>(rd)) {
15 if (cxxrd->isDynamicClass())
16 return false;
17
18 for (const auto &i : cxxrd->bases())
19 if (!isEmptyRecordForLayout(context, i.getType()))
20 return false;
21 }
22
23 for (const auto *i : rd->fields())
24 if (!isEmptyFieldForLayout(context, i))
25 return false;
26
27 return true;
28}
29
31 const FieldDecl *fd) {
32 if (fd->isZeroLengthBitField())
33 return true;
34
35 if (fd->isUnnamedBitField())
36 return false;
37
38 return isEmptyRecordForLayout(context, fd->getType());
39}
40
41namespace {
42
43class X8664ABIInfo : public ABIInfo {
44public:
45 X8664ABIInfo(CIRGenTypes &cgt) : ABIInfo(cgt) {}
46};
47
48class X8664TargetCIRGenInfo : public TargetCIRGenInfo {
49public:
50 X8664TargetCIRGenInfo(CIRGenTypes &cgt)
51 : TargetCIRGenInfo(std::make_unique<X8664ABIInfo>(cgt)) {}
52};
53
54} // namespace
55
56std::unique_ptr<TargetCIRGenInfo>
58 return std::make_unique<X8664TargetCIRGenInfo>(cgt);
59}
60
61ABIInfo::~ABIInfo() noexcept = default;
62
63bool TargetCIRGenInfo::isNoProtoCallVariadic(
64 const FunctionNoProtoType *fnType) const {
65 // The following conventions are known to require this to be false:
66 // x86_stdcall
67 // MIPS
68 // For everything else, we just prefer false unless we opt out.
69 return false;
70}
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition: ASTContext.h:188
This class organizes the cross-module state that is used while lowering AST types to CIR types.
Definition: CIRGenTypes.h:48
Represents a C++ struct/union/class.
Definition: DeclCXX.h:258
Represents a member of a struct/union/class.
Definition: Decl.h:3153
bool isUnnamedBitField() const
Determines whether this is an unnamed bitfield.
Definition: Decl.h:3259
bool isZeroLengthBitField() const
Is this a zero-length bit-field? Such bit-fields aren't really bit-fields at all and instead act as a...
Definition: Decl.cpp:4698
Represents a K&R-style 'int foo()' function, which has no information available about its arguments.
Definition: TypeBase.h:4860
A (possibly-)qualified type.
Definition: TypeBase.h:937
RecordDecl * getAsRecordDecl() const
Retrieves the RecordDecl this type refers to.
Definition: Type.h:41
QualType getType() const
Definition: Decl.h:722
std::unique_ptr< TargetCIRGenInfo > createX8664TargetCIRGenInfo(CIRGenTypes &cgt)
Definition: TargetInfo.cpp:57
bool isEmptyFieldForLayout(const ASTContext &context, const FieldDecl *fd)
isEmptyFieldForLayout - Return true if the field is "empty", that is, either a zero-width bit-field o...
Definition: TargetInfo.cpp:30
bool isEmptyRecordForLayout(const ASTContext &context, QualType t)
isEmptyRecordForLayout - Return true if a structure contains only empty base classes (per isEmptyReco...
Definition: TargetInfo.cpp:7
The JSON file list parser is used to communicate input to InstallAPI.