Class Padding::PaddedType

A class that is subject to padding by the compiler, and hence can introduce waste. Does not include types with virtual member functions, virtual base classes, or multiple base classes. These are excluded due to the complexity of the implementation.

Direct supertypes

Indirect supertypes

Predicates

baseClassEnd

Gets the offset, in bits, of the end of the class’ last base class subobject, or zero if the class has no base classes.

biggestAlignmentUpTo

Gets the largest alignment boundary, in bits, required by a field with (1-based) index less than or equal to index on architecture arch.

biggestFieldSizeUpTo

Gets the largest size, in bits, of the size of a field with (1-based) index less than or equal to index on architecture arch.

dataSize

Gets the data size of this type on architecture arch; that is, the number of bits taken up by data, rather than any kind of padding. Padding of fields that have struct type is considered “data” for the purposes of this definition, since removing it requires reorganizing other parts of the code.

fieldEnd

Gets the 0-based offset, in bits, of the first free bit after field f (which is the indexth field of this type), taking padding into account, on architecture arch.

fieldIndex

Gets the 1-based index for each field.

fieldSize

Gets the size, in bits, of field f on architecture arch.

isPrecise

Holds if, for each architecture, a single padded size is calculated for this type. This is normally the case, but sometimes the same type can be defined in different compilations with different sizes, normally due to use of the preprocessor in its definition.

lastField

Gets the last field of this type.

lastFieldIndex

Gets the 1-based index for the last field.

optimalSize

Gets the optimal size of this type on architecture arch, that is, the sum of the sizes of all fields, ignoring padding between them, but adding any trailing padding required to align the type properly. This is a lower bound on the actual size that can be achieved just by reordering fields, and without reorganizing member structs’ field layouts.

paddedSize

Gets the padded size of this type on architecture arch, in bits. This is its bitSize, rounded up to the next multiple of its alignment.

trailingPadding

Gets the number of bits wasted by padding at the end of this struct.

typeAlignment

Gets the alignment, in bits, of the entire struct/union type for architecture arch.

typeBitSize

Gets the bit size of this type on architecture arch, that is, the size its fields and required padding take up, without including any trailing padding that is necessary.

wastedSpace

Gets the number of bits wasted in this struct definition; that is. the waste between fields plus any waste from trailing padding. Only the space wasted directly in this type is counted, not space wasted in nested structs. Note that for unions, the wasted space is simply the amount of trailing padding, as other fields are not laid out one after another, and hence there is no padding between them.

Inherited predicates

accessOfBaseMember

Gets the access specifier, if any, that a hypothetical member of base would have when viewed as a member of this, given that this member had access specifier fieldInBase. Encodes the rules of C++14 11.2/1 and 11.6/1, except that this predicate includes the case of base = this.

from Class
accessOfBaseMember

Gets the access specifier, if any, that member has when viewed as a member of this, where member may come from a base class of this. Encodes the rules of C++14 11.2/1 and 11.6/1, except that this predicate includes the case of base = this.

from Class
canAccessClass

Holds if a base class base of derived is accessible at this (N4140 11.2/4). When this holds, and derived has only one base subobject of type base, code in this can implicitly convert a pointer to derived into a pointer to base. Conversely, if such a conversion is possible then this predicate holds.

from AccessHolder
canAccessMember

Holds if a non-static member member is accessible at this when named in a class derived that is derived from or equal to the declaring class of member (N4140 11.2/5 and 11.4).

from AccessHolder
couldAccessMember

Holds if a hypothetical non-static member of memberClass with access specifier memberAccess is accessible at this when named in a class derived that is derived from or equal to memberClass (N4140 11.2/5 and 11.4).

from AccessHolder
derivesFrom

Holds if this class derives directly from that.

from Class
explain

Gets a detailed string representation explaining the AST of this type (with all specifiers and nested constructs such as pointers). This is intended to help debug queries and is a very expensive operation; not to be used in production queries.

from Class
findRootCause

Gets the source of this element: either itself or a macro that expanded to this element.

from Element
fromLibrary

Holds if this element may be from a library.

from Element
fromSource

Holds if this element may be from source.

from Element
getABaseClass

Gets a direct base class of this class [N4140 10].

from Class
getABaseClassByteOffset

Gets the byte offset within this of each base class subobject of type baseClass, or zero if baseClass and this are the same type. Both direct and indirect base classes are included. Note that for virtual base classes, and non-virtual base classes thereof, this predicate assumes that this is the type of the complete most-derived object.

from Class
getACanonicalMember

Gets a member declared in this class. If you also want template instantiations of results, see getAMember().

from Class
getACanonicalMemberFunction

Gets a function declared in this class. For template member functions, results include only the template. If you also want instantiations of the template, then use getAMemberFunction() instead.

from Class
getACanonicalMemberVariable

Gets a member variable declared in this class. For template member variables, results include only the template. If you also want instantiations of the template, then use getAMemberVariable() instead.

from Class
getAConstructor

Gets a constructor of this class.

from Class
getADeclaration

Gets a child declaration of this class.

from Class
getADeclarationEntry

Gets a declaration entry corresponding to this declaration. See the comment above this class for an explanation of the relationship between Declaration and DeclarationEntry.

from UserType
getADeclarationLocation

Gets the location of a declaration entry corresponding to this declaration.

from UserType
getADerivation

Gets a class derivation of this class, for example the “public B” in “class D : public B { … };”.

from Class
getADerivedClass

Gets a class that is directly derived from this class [N4140 10].

from Class
getAField

Gets a field of this class.

from Class
getAFile

Gets a file where this element occurs.

from Declaration
getAFriendDecl

Gets a friend declaration in this class.

from Class
getALinkTarget

Gets a link target which references this class.

from Class
getAMember

Gets a member declared in this class. For template members, this may be either the template or an instantiation of that template. If you only want the template, see getACanonicalMember().

from Class
getAMember

Gets the (zero-based) indexth canonical member declared in this class and, if that member is a template, all instantiations of that template. If you only want the canonical member, see getCanonicalMember(int).

from Class
getAMemberFunction

Gets a function declared in this class. For template member functions, results include both the template and the instantiations of that template. If you only want the template, then use getACanonicalMemberFunction() instead.

from Class
getAMemberVariable

Gets a member variable declared in this class. For template member variables, results include both the template and the instantiations of that template. If you only want the template, then use getACanonicalMemberVariable() instead.

from Class
getANameQualifier

Gets a name qualifier for which this is the qualifying namespace or user-defined type. For example: class X is the NameQualifyingElement and X:: is the NameQualifier.

from NameQualifyingElement
getANestedType

Gets a type declared in this class.

from Class
getAPrivateCanonicalMember

Gets a private canonical member declared in this class. If you also want template instantiations of results, see getAPrivateMember().

from Class
getAPrivateMember

Gets a private member declared in this class. For template members, this may be either the template or an instantiation of that template. For just the template, use getAPrivateCanonicalMember().

from Class
getAProtectedCanonicalMember

Gets a protected canonical member declared in this class. If you also want template instantiations of results, see getAProtectedMember().

from Class
getAProtectedMember

Gets a protected member declared in this class. For template members, this may be either the template or an instantiation of that template. For just the template, use getAProtectedCanonicalMember().

from Class
getAPublicCanonicalMember

Gets a public canonical member declared in this class. If you also want template instantiations of results, see getAPublicMember().

from Class
getAPublicMember

Gets a public member declared in this class. For template members, this may be either the template or an instantiation of that template. For just the template, use getAPublicCanonicalMember().

from Class
getASpecifierfrom UserType
getAStaticMember

Gets a static member declared in this class.

from Class
getATemplateArgument

Gets a template argument used to instantiate this class from a class template. When called on a class template, this will return a template parameter.

from Class
getATypeNameUse

Gets as many places as possible where this type is used by name in the source after macros have been replaced (in particular, therefore, this will find type name uses caused by macros). Note that all type name uses within instantiations are currently excluded - this is too draconian in the absence of indexing prototype instantiations of functions, and is likely to improve in the future. At present, the method takes the conservative approach of giving valid type name uses, but not necessarily all type name uses.

from Type
getAlignment

The alignment of this type in bytes (on the machine where facts were extracted).

from Class
getAnAttribute

Gets an attribute of this type.

from Type
getCanonicalMember

Gets the (zero-based) indexth member declared in this class. If you also want template instantiations of results, see getAMember(int).

from Class
getDeclaringType

Gets the class where this member is declared, if it is a member. For templates, both the template itself and all instantiations of the template are considered to have the same declaring class.

from Declaration
getDefinition

Gets the declaration entry corresponding to this declaration that is a definition, if any.

from UserType
getDefinitionLocation

the location of the definition

from UserType
getDerivationfrom Class
getDestructor

Gets the destructor of this class, if any.

from Class
getEnclosingAccessHolder

Gets the nearest enclosing AccessHolder.

from UserType
getEnclosingElement

Gets the closest Element enclosing this one.

from Element
getEnclosingFunction

Gets the function that directly encloses this type (if any).

from UserType
getFile

Gets the primary file where this element occurs.

from Element
getLocation

Gets the preferred location of this declaration, if any.

from UserType
getMember

DEPRECATED: Use getCanonicalMember(int) or getAMember(int) instead. Gets the indexth member of this class.

from Class
getMetrics

Gets the metric class.

from Class
getName

the name of this type

from UserType
getNamespace

Gets the innermost namespace which contains this declaration.

from Declaration
getNumMember

DEPRECATED: As this includes a somewhat arbitrary number of template instantiations, it is unlikely to do what you need. Gets the number of members that this class has. This includes both templates that are in this class, and instantiations of those templates.

from Class
getNumberOfTemplateArguments

Gets the number of template arguments for this class.

from Class
getParentScope

Gets the parent scope of this Element, if any. A scope is a Type (Class / Enum), a Namespace, a Block, a Function, or certain kinds of Statement.

from Element
getPointerIndirectionLevel

Gets the pointer indirection level of this type.

from Type
getQualifiedName

Gets the name of the declaration, fully qualified with its namespace. For example: “A::B::C::myfcn”.

from Declaration
getSimpleName

the simple name of this type, without any template parameters

from UserType
getSize

Gets the size of this type in bytes.

from Type
getTemplateArgument

Gets the ith template argument used to instantiate this class from a class template. When called on a class template, this will return the ith template parameter.

from Class
getUnderlyingType

Gets this type after typedefs have been resolved.

from Type
getUnspecifiedType

Gets this type after specifiers have been deeply stripped and typedefs have been resolved.

from Type
getUuid

Gets the UUID that associated with this class via the __declspec(uuid) attribute.

from Class
getVirtualBaseClassByteOffset

Gets the byte offset of virtual base class subobject base within a most-derived object of class this. The virtual base can be a direct or indirect virtual base of this. Does not hold if this is an uninstantiated template. See ClassDerivation.getByteOffset for offsets of non-virtual base classes.

from Class
hasConstructor

Holds if this class has a constructor.

from Class
hasCopyAssignmentOperator

Holds if this class has a copy assignment operator that is either explicitly declared (though possibly = delete) or is auto-generated, non-trivial and called from somewhere.

from Class
hasCopyConstructor

Holds if this class has a copy constructor that is either explicitly declared (though possibly = delete) or is auto-generated, non-trivial and called from somewhere.

from Class
hasDeclaringType

Holds if this declaration is a member of a class/struct/union.

from Declaration
hasDefinition

Holds if the declaration has a definition.

from Declaration
hasDestructor

Holds if this class has a destructor.

from Class
hasGeneratedCopyAssignmentOperator

DEPRECATED: name changed to hasImplicitCopyAssignmentOperator to reflect that = default members are no longer included.

from Class
hasGeneratedCopyConstructor

DEPRECATED: name changed to hasImplicitCopyConstructor to reflect that = default members are no longer included.

from Class
hasGlobalName

Holds if this declaration has the given name in the global namespace.

from Declaration
hasImplicitCopyAssignmentOperator

Holds if this class has an implicitly-declared copy assignment operator that is not deleted. This predicate is more accurate than checking if this class has a CopyAssignmentOperator ca where ca.isCompilerGenerated() since such a CopyAssignmentOperator may not exist in the database if (1) it is never called or (2) it is trivial, meaning that it is equivalent to memcpy.

from Class
hasImplicitCopyConstructor

Holds if this class has an implicitly-declared copy constructor that is not deleted. This predicate is more accurate than checking if this class has a CopyConstructor cc where cc.isCompilerGenerated() since such a CopyConstructor may not exist in the database if (1) it is never called or (2) it is trivial, meaning that it is equivalent to memcpy.

from Class
hasNamefrom UserType
hasPrivateBaseClass

Holds if this class has a private class derivation, for example the “private B” in “class D : private B { … };”.

from Class
hasProtectedBaseClass

Holds if this class has a protected class derivation, for example the “protected B” in “class D : protected B { … };”.

from Class
hasPublicBaseClass

Holds if this class has a public class derivation, for example the “public B” in “class D : public B { … };”.

from Class
hasQualifiedNamefrom Declaration
hasSpecifierfrom UserType
hasVirtualBaseClass

Holds if this class has a virtual class derivation, for example the “virtual public B” in “class D : virtual public B { … };”.

from Class
implicitCopyAssignmentOperatorDeleted

Holds if the compiler would be unable to generate a copy assignment operator for this class. This predicate implements the rules listed here: http://en.cppreference.com/w/cpp/language/copy_assignment#Deleted_implicitly-declared_copy_assignment_operator

from Class
implicitCopyConstructorDeleted

Holds if the compiler would be unable to generate a copy constructor for this class. This predicate implements the rules listed here: http://en.cppreference.com/w/cpp/language/copy_constructor#Deleted_implicitly-declared_copy_constructor

from Class
inMemberOrFriendOf

Holds if this can access private members of class c.

from AccessHolder
internal_getAnAdditionalSpecifier

Internal – should be protected when QL supports such a flag. Subtypes override this to recursively get specifiers that are not attached directly to this @type in the database but arise through type aliases such as typedef and decltype.

from Type
involvesReference

Holds if this type involves a reference.

from Type
involvesTemplateParameter

Holds if this type involves a template parameter.

from Class
isAbstract

Holds if this class is abstract, in other words whether it declares one or more pure virtual member functions.

from Class
isAffectedByMacro

Holds if this element is affected in any way by a macro. All elements that are totally or partially generated by a macro are included, so this is a super-set of isInMacroExpansion.

from Element
isAnonymousfrom UserType
isConst

Holds if this type is const.

from Type
isConstructedFrom

Holds if this class is constructed from another class as a result of template instantiation. It originates either from a class template or from a class nested in a class template.

from Class
isDeeplyConst

Holds if this type is constant and only contains constant types. For instance, a char *const is a constant type, but not deeply constant, because while the pointer can’t be modified the character can. The type const char *const* is a deeply constant type though - both the pointer and what it points to are immutable.

from Type
isDeeplyConstBelow

Holds if this type is constant and only contains constant types, excluding the type itself. It is implied by Type.isDeeplyConst() and is just used to implement that predicate. For example, const char *const is deeply constant and deeply constant below, but const char * is only deeply constant below (the pointer can be changed, but not the underlying char). char *const is neither (it is just const).

from Class
isDefinedfrom Declaration
isFinal

Holds if this class was declared ‘final’.

from Class
isFromTemplateInstantiation

Holds if this Element is a part of a template instantiation (but not the template itself).

from Element
isFromUninstantiatedTemplate

Holds if this Element is part of a template template (not if it is part of an instantiation of template). This means it is represented in the database purely as syntax and without guarantees on the presence or correctness of type-based operations such as implicit conversions.

from Element
isInMacroExpansion

Holds if this element comes from a macro expansion. Only elements that are entirely generated by a macro are included - for elements that partially come from a macro, see isAffectedByMacro.

from Element
isLocal

Whether this is a local type (i.e. a type that has a directly-enclosing function).

from UserType
isMember

Holds if this declaration is a member of a class/struct/union.

from Declaration
isPOD

Holds if this class is a POD (Plain Old Data) class [N4140 9(10)].

from Class
isPolymorphic

Holds if or not this class is polymorphic (has a virtual function, or inherits one).

from Class
isStandardLayout

Holds if this class is a standard-layout class [N4140 9(7)]. Also holds for structs in C programs.

from Class
isStatic

Holds if this declaration is static.

from Declaration
isTopLevel

Holds if this declaration is a top-level declaration.

from Declaration
isVolatile

Holds if this type is volatile.

from Type
refersTo

Holds if this type refers to type t (by default, a type always refers to itself).

from Type
refersToDirectly

Holds if this type refers to type t directly.

from Class
resolveTypedefs

Gets this type with any typedefs resolved. For example, given typedef C T, this would resolve const T& to const C&. Note that this will only work if the resolved type actually appears on its own elsewhere in the program.

from Type
stripTopLevelSpecifiers

Gets this type after any top-level specifiers and typedefs have been stripped.

from Type
stripType

Gets the type stripped of pointers, references and cv-qualifiers, and resolving typedefs. For example, given typedef const C& T, stripType returns C.

from Type
toString

Gets a textual representation of this element.

from Declaration

Charpred