Path: blob/main/contrib/llvm-project/clang/lib/CIR/CodeGen/TargetInfo.cpp
213799 views
#include "TargetInfo.h"1#include "ABIInfo.h"23using namespace clang;4using namespace clang::CIRGen;56bool clang::CIRGen::isEmptyRecordForLayout(const ASTContext &context,7QualType t) {8const RecordType *rt = t->getAs<RecordType>();9if (!rt)10return false;1112const RecordDecl *rd = rt->getDecl();1314// If this is a C++ record, check the bases first.15if (const CXXRecordDecl *cxxrd = dyn_cast<CXXRecordDecl>(rd)) {16if (cxxrd->isDynamicClass())17return false;1819for (const auto &I : cxxrd->bases())20if (!isEmptyRecordForLayout(context, I.getType()))21return false;22}2324for (const auto *I : rd->fields())25if (!isEmptyFieldForLayout(context, I))26return false;2728return true;29}3031bool clang::CIRGen::isEmptyFieldForLayout(const ASTContext &context,32const FieldDecl *fd) {33if (fd->isZeroLengthBitField())34return true;3536if (fd->isUnnamedBitField())37return false;3839return isEmptyRecordForLayout(context, fd->getType());40}4142namespace {4344class X8664ABIInfo : public ABIInfo {45public:46X8664ABIInfo(CIRGenTypes &cgt) : ABIInfo(cgt) {}47};4849class X8664TargetCIRGenInfo : public TargetCIRGenInfo {50public:51X8664TargetCIRGenInfo(CIRGenTypes &cgt)52: TargetCIRGenInfo(std::make_unique<X8664ABIInfo>(cgt)) {}53};5455} // namespace5657std::unique_ptr<TargetCIRGenInfo>58clang::CIRGen::createX8664TargetCIRGenInfo(CIRGenTypes &cgt) {59return std::make_unique<X8664TargetCIRGenInfo>(cgt);60}6162ABIInfo::~ABIInfo() noexcept = default;6364bool TargetCIRGenInfo::isNoProtoCallVariadic(65const FunctionNoProtoType *fnType) const {66// The following conventions are known to require this to be false:67// x86_stdcall68// MIPS69// For everything else, we just prefer false unless we opt out.70return false;71}727374