clang 8.0.0

Functions
RecordLayoutBuilder.cpp File Reference
`#include "clang/AST/RecordLayout.h"`
`#include "clang/AST/ASTContext.h"`
`#include "clang/AST/ASTDiagnostic.h"`
`#include "clang/AST/Attr.h"`
`#include "clang/AST/CXXInheritance.h"`
`#include "clang/AST/Decl.h"`
`#include "clang/AST/DeclCXX.h"`
`#include "clang/AST/DeclObjC.h"`
`#include "clang/AST/Expr.h"`
`#include "clang/Basic/TargetInfo.h"`
`#include "llvm/ADT/SmallSet.h"`
`#include "llvm/Support/Format.h"`
`#include "llvm/Support/MathExtras.h"`
Include dependency graph for RecordLayoutBuilder.cpp:

Go to the source code of this file.

## Functions
static uint64_t | roundUpSizeToCharAlignment (uint64_t Size, const ASTContext &Context)
static unsigned | getPaddingDiagFromTagKind (TagTypeKind Tag)
| Get diagnostic select index for tag kind for field padding diagnostic message. More...
static const CXXMethodDecl * | computeKeyFunction (ASTContext &Context, const CXXRecordDecl *RD)
static bool | mustSkipTailPadding (TargetCXXABI ABI, const CXXRecordDecl *RD)
| Does the target C++ ABI require us to skip over the tail-padding of the given class (considering it as a base class) when allocating objects? More...
static bool | isMsLayout (const ASTContext &Context)
static bool | recordUsesEBO (const RecordDecl *RD)
static bool | RequiresVtordisp (const llvm::SmallPtrSetImpl< const CXXRecordDecl *> &BasesWithOverriddenMethods, const CXXRecordDecl *RD)
static uint64_t | getFieldOffset (const ASTContext &C, const FieldDecl *FD)
static void | PrintOffset (raw_ostream &OS, CharUnits Offset, unsigned IndentLevel)
static void | PrintBitFieldOffset (raw_ostream &OS, CharUnits Offset, unsigned Begin, unsigned Width, unsigned IndentLevel)
static void | PrintIndentNoOffset (raw_ostream &OS, unsigned IndentLevel)
static void | DumpRecordLayout (raw_ostream &OS, const RecordDecl *RD, const ASTContext &C, CharUnits Offset, unsigned IndentLevel, const char *Description, bool PrintSizeInfo, bool IncludeVirtualBases)

## Function Documentation

## ◆ computeKeyFunction()

static const CXXMethodDecl* computeKeyFunction | ( | ASTContext & | Context,
|  | const CXXRecordDecl * | RD
| ) |  |
| static

Definition at line 2030 of file RecordLayoutBuilder.cpp.

References clang::TargetCXXABI::canKeyFunctionBeInline(), Diag(), clang::TargetInfo::getCXXABI(), clang::ASTContext::getDiagnostics(), clang::ASTContext::getLangOpts(), clang::ASTContext::getTargetInfo(), clang::CXXRecordDecl::getTemplateSpecializationKind(), clang::Decl::hasAttr(), clang::NamedDecl::isExternallyVisible(), clang::FunctionDecl::isInlineSpecified(), clang::CXXRecordDecl::isPolymorphic(), clang::CXXRecordDecl::methods(), clang::DiagnosticsEngine::Report(), clang::TSK_ExplicitInstantiationDeclaration, clang::TSK_ExplicitInstantiationDefinition, and clang::TSK_ImplicitInstantiation.

Referenced by clang::ASTContext::getCurrentKeyFunction().

## ◆ DumpRecordLayout()

static void DumpRecordLayout | ( | raw_ostream & | OS,
|  | const RecordDecl * | RD,
|  | const ASTContext & | C,
|  | CharUnits | Offset,
|  | unsigned | IndentLevel,
|  | const char * | Description,
|  | bool | PrintSizeInfo,
|  | bool | IncludeVirtualBases
| ) |  |
| static

Definition at line 3233 of file RecordLayoutBuilder.cpp.

References Begin, clang::C, clang::RecordDecl::field_begin(), clang::RecordDecl::field_end(), clang::CharUnits::fromQuantity(), clang::ASTRecordLayout::getAlignment(), clang::Type::getAs(), clang::QualType::getAsString(), clang::ASTContext::getASTRecordLayout(), clang::ASTRecordLayout::getBaseClassOffset(), clang::FieldDecl::getBitWidthValue(), clang::ASTRecordLayout::getDataSize(), clang::RecordType::getDecl(), clang::ASTRecordLayout::getFieldOffset(), clang::NamedDecl::getName(), clang::ASTRecordLayout::getNonVirtualAlignment(), clang::ASTRecordLayout::getNonVirtualSize(), clang::ASTRecordLayout::getPrimaryBase(), clang::CharUnits::getQuantity(), clang::ASTRecordLayout::getSize(), clang::ValueDecl::getType(), clang::ASTContext::getTypeDeclType(), clang::ASTRecordLayout::getVBaseClassOffset(), clang::ASTRecordLayout::getVBaseOffsetsMap(), clang::ASTRecordLayout::getVBPtrOffset(), clang::ASTRecordLayout::hasOwnVBPtr(), clang::ASTRecordLayout::hasOwnVFPtr(), clang::FieldDecl::isBitField(), isMsLayout(), PrintBitFieldOffset(), PrintIndentNoOffset(), PrintOffset(), clang::ASTContext::toBits(), and clang::ASTContext::toCharUnitsFromBits().

Referenced by clang::ASTContext::DumpRecordLayout(), and clang::ASTContext::getTypeUnadjustedAlign().

## ◆ getFieldOffset()

static uint64_t getFieldOffset | ( | const ASTContext & | C,
|  | const FieldDecl * | FD
| ) |  |
| static

Definition at line 3101 of file RecordLayoutBuilder.cpp.

References clang::ASTContext::getASTRecordLayout(), clang::FieldDecl::getFieldIndex(), clang::ASTRecordLayout::getFieldOffset(), and clang::FieldDecl::getParent().

Referenced by clang::ASTContext::getFieldOffset(), getFieldSize(), and clang::ASTContext::getTypeUnadjustedAlign().

## ◆ getPaddingDiagFromTagKind()

static unsigned getPaddingDiagFromTagKind | ( | TagTypeKind | Tag | ) |
| static

Get diagnostic select index for tag kind for field padding diagnostic message.

WARNING: Indexes apply to particular diagnostics only!

Returns
  diagnostic select index.

Definition at line 1979 of file RecordLayoutBuilder.cpp.

References Diag(), clang::TargetInfo::getCharWidth(), clang::NamedDecl::getIdentifier(), clang::Decl::getLocation(), clang::FieldDecl::getParent(), clang::TagDecl::getTagKind(), clang::ASTContext::getTargetInfo(), clang::ASTContext::getTypeDeclType(), clang::SourceLocation::isInvalid(), clang::TTK_Class, clang::TTK_Interface, and clang::TTK_Struct.

## ◆ isMsLayout()

static bool isMsLayout | ( | const ASTContext & | Context | ) |
| static

Definition at line 2157 of file RecordLayoutBuilder.cpp.

References clang::TargetInfo::getCXXABI(), clang::ASTContext::getTargetInfo(), and clang::TargetCXXABI::isMicrosoft().

Referenced by clang::ASTContext::DumpRecordLayout(), DumpRecordLayout(), and clang::ASTContext::getASTRecordLayout().

## ◆ mustSkipTailPadding()

static bool mustSkipTailPadding | ( | TargetCXXABI | ABI,
|  | const CXXRecordDecl * | RD
| ) |  |
| static

Does the target C++ ABI require us to skip over the tail-padding of the given class (considering it as a base class) when allocating objects?

Definition at line 2118 of file RecordLayoutBuilder.cpp.

References clang::TargetCXXABI::AlwaysUseTailPadding, clang::TargetCXXABI::getTailPaddingUseRules(), clang::CXXRecordDecl::isCXX11StandardLayout(), clang::CXXRecordDecl::isPOD(), clang::CXXRecordDecl::isTrivial(), clang::TargetCXXABI::UseTailPaddingUnlessPOD03, and clang::TargetCXXABI::UseTailPaddingUnlessPOD11.

## ◆ PrintBitFieldOffset()

static void PrintBitFieldOffset | ( | raw_ostream & | OS,
|  | CharUnits | Offset,
|  | unsigned | Begin,
|  | unsigned | Width,
|  | unsigned | IndentLevel
| ) |  |
| static

Definition at line 3210 of file RecordLayoutBuilder.cpp.

References clang::CharUnits::getQuantity().

Referenced by DumpRecordLayout().

## ◆ PrintIndentNoOffset()

static void PrintIndentNoOffset | ( | raw_ostream & | OS,
|  | unsigned | IndentLevel
| ) |  |
| static

Definition at line 3228 of file RecordLayoutBuilder.cpp.

Referenced by DumpRecordLayout().

## ◆ PrintOffset()

static void PrintOffset | ( | raw_ostream & | OS,
|  | CharUnits | Offset,
|  | unsigned | IndentLevel
| ) |  |
| static

Definition at line 3204 of file RecordLayoutBuilder.cpp.

References clang::CharUnits::getQuantity().

Referenced by DumpRecordLayout().

## ◆ recordUsesEBO()

static bool recordUsesEBO | ( | const RecordDecl * | RD | ) |
| static

Definition at line 2590 of file RecordLayoutBuilder.cpp.

References clang::CharUnits::alignTo(), clang::ASTRecordLayout::endsWithZeroSizedObject(), clang::RecordDecl::fields(), clang::CharUnits::fromQuantity(), clang::ASTContext::getASTRecordLayout(), clang::Decl::getAttr(), clang::FieldDecl::getBitWidthValue(), clang::ASTContext::getCharWidth(), clang::ASTRecordLayout::getNonVirtualSize(), clang::ASTRecordLayout::getRequiredAlignment(), clang::Decl::hasAttr(), clang::FieldDecl::isBitField(), clang::CXXRecordDecl::isEmpty(), clang::CharUnits::isZero(), clang::ASTRecordLayout::leadsWithZeroSizedBase(), max(), min(), clang::LangOptions::MSVC2015, Offset, clang::ASTContext::toBits(), clang::ASTContext::toCharUnitsFromBits(), clang::CXXRecordDecl::vbases(), and clang::CharUnits::Zero().

## ◆ RequiresVtordisp()

static bool RequiresVtordisp | ( | const llvm::SmallPtrSetImpl< const CXXRecordDecl *> & | BasesWithOverriddenMethods,
|  | const CXXRecordDecl * | RD
| ) |  |
| static

Definition at line 2882 of file RecordLayoutBuilder.cpp.

References clang::CXXRecordDecl::bases(), clang::ASTContext::getASTRecordLayout(), clang::CXXRecordDecl::getMSVtorDispMode(), clang::CXXMethodDecl::getParent(), clang::ASTRecordLayout::getVBaseOffsetsMap(), clang::ASTRecordLayout::hasExtendableVFPtr(), clang::CXXRecordDecl::hasUserDeclaredConstructor(), clang::CXXRecordDecl::hasUserDeclaredDestructor(), clang::CXXRecordDecl::methods(), clang::CXXMethodDecl::overridden_methods(), and clang::CXXRecordDecl::vbases().

## ◆ roundUpSizeToCharAlignment()

static uint64_t roundUpSizeToCharAlignment | ( | uint64_t | Size,
|  | const ASTContext & | Context
| ) |  |
| static

Definition at line 1376 of file RecordLayoutBuilder.cpp.

References clang::TypeInfo::Align, clang::CharUnits::alignTo(), Diag(), clang::CharUnits::fromQuantity(), clang::Type::getAs(), clang::ASTContext::getAsArrayType(), clang::ASTContext::getBaseElementType(), clang::FieldDecl::getBitWidthValue(), clang::TargetInfo::getCharAlign(), clang::TargetInfo::getCharWidth(), clang::ArrayType::getElementType(), clang::NamedDecl::getIdentifier(), clang::ASTContext::getLangOpts(), clang::Decl::getLocation(), clang::Decl::getMaxAlignment(), clang::Type::getPointeeType(), clang::TargetInfo::getPointerAlign(), clang::TargetInfo::getPointerWidth(), clang::CharUnits::getQuantity(), clang::ASTContext::getTargetAddressSpace(), clang::ASTContext::getTargetInfo(), clang::TargetInfo::getTriple(), clang::ValueDecl::getType(), clang::ASTContext::getTypeAlignInChars(), clang::ASTContext::getTypeDeclType(), clang::ASTContext::getTypeInfo(), clang::ASTContext::getTypeInfoInChars(), clang::ASTContext::getTypeSize(), clang::ASTContext::getTypeSizeInChars(), clang::TargetInfo::getZeroLengthBitfieldBoundary(), clang::Decl::hasAttr(), clang::FieldDecl::isBitField(), clang::CXXRecordDecl::isEmpty(), clang::Type::isIncompleteArrayType(), clang::QualType::isNull(), clang::CharUnits::isZero(), max(), min(), clang::CharUnits::One(), clang::ASTContext::toBits(), clang::ASTContext::toCharUnitsFromBits(), clang::ASTContext::UnsignedCharTy, clang::ASTContext::UnsignedIntTy, clang::ASTContext::UnsignedLongLongTy, clang::ASTContext::UnsignedLongTy, clang::ASTContext::UnsignedShortTy, clang::TargetInfo::useBitFieldTypeAlignment(), clang::TargetInfo::useExplicitBitFieldAlignment(), clang::TargetInfo::useZeroLengthBitfieldAlignment(), clang::TypeInfo::Width, and clang::CharUnits::Zero().