construction
cpp.Construction.rawArray
Section titled “cpp.Construction.rawArray”def Construction.rawArray : StringThe internal functions a container’s generated code calls for its elements (as std::allocator and
std::allocator_traits do): a block of elements allocated without constructing them (#rawArray(new T[n])), an object
constructed at a pointer with arguments (placement new, #construct(p, args)), one destroyed there (#destroy(p), nothing
for an element without a destructor), a block released without destroying its elements (#releaseRaw(p)), an object
moved to a pointer as a whole (#relocate(to, from): the source is not destroyed afterwards, as a moved-from vector or
string owns nothing).
cpp.Construction.constructAt
Section titled “cpp.Construction.constructAt”def Construction.constructAt : StringPlacement new (see Construction.rawArray).
cpp.Construction.destroyAt
Section titled “cpp.Construction.destroyAt”def Construction.destroyAt : StringAn object’s destruction at a pointer (see Construction.rawArray).
cpp.Construction.releaseRaw
Section titled “cpp.Construction.releaseRaw”def Construction.releaseRaw : StringA block’s release without destroying its elements (see Construction.rawArray).
cpp.Construction.valueConstructAt
Section titled “cpp.Construction.valueConstructAt”def Construction.valueConstructAt : StringThe internal function value-initializing an object at a pointer (::new (p) T(), [dcl.init]p9): a scalar zero,
an object of a class by its default constructor.
cpp.Construction.relocate
Section titled “cpp.Construction.relocate”def Construction.relocate : StringAn object moved as a whole (see Construction.rawArray).
cpp.TypedCpp
Section titled “cpp.TypedCpp”def TypedCpp : TypeA typed statement of C++.
cpp.Assigning
Section titled “cpp.Assigning”def Assigning : TypeHow a value is converted for storing into an object of a type (the dialect’s assignment conversion).
cpp.Choosing
Section titled “cpp.Choosing”record ChoosingWhat choosing a constructor uses: the types, the assignment conversion, and the checker of expressions.
cpp.Constructing
Section titled “cpp.Constructing”record ConstructingWhat checking a construction as a statement uses: what choosing uses, and the checker of statements.
cpp.Construction.resolve
Section titled “cpp.Construction.resolve”def Construction.resolve (types : TypeExtension Cpp.constructs) (g : Globals Cpp.constructs) (t : TypeSyntax) : Option (Ty Cpp.constructs)A written type resolved and completed (a class’s struct with its members).
cpp.Construction.promotes
Section titled “cpp.Construction.promotes”def Construction.promotes (p : Platform) (a : Ty Cpp.constructs) (b : Ty Cpp.constructs) : BoolWhether a type converts to another by a promotion ([conv.prom], [conv.fpprom]): an integer type to its promoted type, float to double.
cpp.Construction.rank
Section titled “cpp.Construction.rank”def Construction.rank (k : Choosing) (g : Globals Cpp.constructs) (n : NodeId) (parameter : Ty Cpp.constructs) (argument : TypedExpr Cpp.constructs) : Option NatHow well an argument matches a parameter ([over.ics.rank]), if it can be passed at all: by the conversion, 0 the same type (or a reference bound to it), 1 a promotion, 2 any other standard conversion, 3 a pointer converted to void * or bool, 4 a user-defined conversion; four times that, two more for const added to a pointer’s pointee and one more for an rvalue bound to an lvalue reference (worse than to an rvalue reference, [over.ics.rank]p3.2.3).
cpp.Construction.better
Section titled “cpp.Construction.better”def Construction.better (a : List Nat) (b : List Nat) : BoolWhether one candidate’s ranks are no worse than another’s for every argument and better for one ([over.match.best]p2).
cpp.Construction.ranks
Section titled “cpp.Construction.ranks”def Construction.ranks (k : Choosing) (g : Globals Cpp.constructs) (n : NodeId) (args : List (TypedExpr Cpp.constructs)) (f : Constructor) : Option (List Nat)The ranks of a constructor’s parameters for the arguments, if every argument can be passed (the parameters after
this, from the lowered function’s signature).
cpp.Viable
Section titled “cpp.Viable”record ViableA viable constructor for a construction’s arguments: the constructor (a constructor template’s with its instance as the function), its parameters’ ranks, and for a constructor template the template and the arguments deduced (its instance is asked for when the program does not have it yet).
cpp.Construction.templateViable
Section titled “cpp.Construction.templateViable”def Construction.templateViable (k : Choosing) (g : Globals Cpp.constructs) (n : NodeId) (args : List (TypedExpr Cpp.constructs)) (f : Constructor) : Option ViableThe constructor template f’s instance for the arguments args, if viable ([temp.deduct.call], [over.match.funcs]p7;
k checks, in the globals g, at the node n): the template arguments deduced from the arguments’ types (the function
template f.function is the constructor lowered,
this first, Classes.constructorTemplateItems; a default template argument whose substitution fails is no
candidate), each argument ranked against its parameter with the deduced arguments in place.
cpp.Construction.noWorse
Section titled “cpp.Construction.noWorse”def Construction.noWorse (a : List Nat) (b : List Nat) : BoolWhether a candidate’s ranks a are no worse than another’s, b, for every argument.
cpp.Viable.beats
Section titled “cpp.Viable.beats”def Viable.beats (c : Viable) (d : Viable) : BoolWhether the viable constructor c is better than d ([over.match.best]p2): no worse for every argument, and better for one, or c is not a template’s instance and d is (p2.4).
cpp.Viable.chosen
Section titled “cpp.Viable.chosen”def Viable.chosen (g : Globals Cpp.constructs) (v : Viable) : CheckResult Cpp.constructs ConstructorThe chosen constructor v, its function the program’s (in the globals g): a constructor template’s instance the program does not have yet is asked for (the program is prepared and checked again with it, as a function template’s).
cpp.Construction.choose
Section titled “cpp.Construction.choose”def Construction.choose (k : Choosing) (g : Globals Cpp.constructs) (n : NodeId) (cls : ClassMembers) (args : List (TypedExpr Cpp.constructs)) : CheckResult Cpp.constructs ConstructorThe constructor for the arguments: among those taking as many (or more, with defaults), the ones every argument can be passed to, and of
those the one better than every other ([over.match.best]); a constructor template is a candidate by the instance its
deduction gives (Construction.templateViable); none is no match, several are ambiguous.
cpp.Construction.trivialCopy
Section titled “cpp.Construction.trivialCopy”def Construction.trivialCopy (k : Constructing) (c : StatementContext Cpp.constructs) (env : Env Cpp.constructs) (n : NodeId) (cls : ClassMembers) (object : Expr) (args : List Expr) : Option (CheckResult Cpp.constructs (TypedStmt Cpp.constructs))A copy of an object of a class without a copy constructor (its implicit one is trivial, [class.copy.ctor]p12): the other object (of the class, or of one derived from it: its base subobject) stored bit for bit. None unless the one argument is such an object.
cpp.Construction.constructorCall
Section titled “cpp.Construction.constructorCall”def Construction.constructorCall (k : Constructing) (c : StatementContext Cpp.constructs) (env : Env Cpp.constructs) (n : NodeId) (cls : ClassMembers) (object : Expr) (args : List Expr) : CheckResult Cpp.constructs (TypedStmt Cpp.constructs)The call of a class’s constructor on an object (its address and the arguments), checked as a statement: the constructor chosen for the arguments, accessible here.
cpp.TypedExpr.isTemporary
Section titled “cpp.TypedExpr.isTemporary”def TypedExpr.isTemporary {L : Constructs} (e : TypedExpr L) : BoolWhether an expression is a temporary the full expression ends (a call’s result, kept in a variable named for it).
cpp.Construction.fromTemporary
Section titled “cpp.Construction.fromTemporary”def Construction.fromTemporary (k : Constructing) (c : StatementContext Cpp.constructs) (env : Env Cpp.constructs) (n : NodeId) (x : DeclId) (name : String) (u : Ty Cpp.constructs) (args : List Expr) : Option (CheckResult Cpp.constructs (TypedStmt Cpp.constructs))An object initialized by a temporary of its class (a call’s result): the temporary becomes the object, without a copy ([dcl.init]p17.6.1, C++17’s guaranteed elision); it is handed over, so the full expression’s end does not destroy it. None when the initializer is anything else.
cpp.Construction.declareOf
Section titled “cpp.Construction.declareOf”def Construction.declareOf (k : Constructing) (c : StatementContext Cpp.constructs) (env : Env Cpp.constructs) (n : NodeId) (x : DeclId) (name : String) (u : Ty Cpp.constructs) (cls : ClassMembers) (args : List Expr) : CheckResult Cpp.constructs (TypedStmt Cpp.constructs)A declaration of an object of a class with constructors (its type resolved): initialized by a temporary of its class, else reserved, constructed with the arguments, and only then an object (a constructor that throws leaves none to destroy, [except.ctor]p3). A const object is not const while it is constructed ([class.ctor]p5).
cpp.Construction.declareObject
Section titled “cpp.Construction.declareObject”def Construction.declareObject (k : Constructing) (c : StatementContext Cpp.constructs) (env : Env Cpp.constructs) (n : NodeId) (x : DeclId) (name : String) (t : TypeSyntax) (cls : ClassMembers) (args : List Expr) : CheckResult Cpp.constructs (TypedStmt Cpp.constructs)A declaration of an object of a class with constructors, by its written type.
cpp.Construction.arguments
Section titled “cpp.Construction.arguments”def Construction.arguments (i : Option Init) : Option (List Expr)The arguments of an initializer for a constructor: none, the expression, or the braced list’s expressions.
cpp.Construction.classOf
Section titled “cpp.Construction.classOf”def Construction.classOf (g : Globals Cpp.constructs) (t : TypeSyntax) : Option ClassMembersThe class with constructors a declaration’s type names, if any.
cpp.Construction.scalar
Section titled “cpp.Construction.scalar”def Construction.scalar (k : Constructing) (c : StatementContext Cpp.constructs) (env : Env Cpp.constructs) (n : NodeId) (y : String) (args : List Expr) : CheckResult Cpp.constructs (TypedStmt Cpp.constructs)A member that is not of a class with constructors initialized in a constructor: the value (zero for x())
converted to the member’s type and stored, even into a const member (an initialization, not an assignment).
cpp.Construction.guarded
Section titled “cpp.Construction.guarded”def Construction.guarded (k : Constructing) (c : StatementContext Cpp.constructs) (env : Env Cpp.constructs) (n : NodeId) (y : String) (call : TypedStmt Cpp.constructs) : CheckResult Cpp.constructs (TypedStmt Cpp.constructs)A constructed member’s guard after its construction: a pointer to it, declared in the constructor’s scope (named, so it is no temporary of the full expression and lasts to the scope’s end), which destroys it when an exception leaves the constructor ([except.ctor]p3: the constructed members and bases, in reverse order).
cpp.Construction.member
Section titled “cpp.Construction.member”def Construction.member (k : Constructing) (c : StatementContext Cpp.constructs) (env : Env Cpp.constructs) (n : NodeId) (y : String) (args : List Expr) : CheckResult Cpp.constructs (TypedStmt Cpp.constructs)A member initialized in a constructor: one of a class with constructors is constructed (this->y with the
arguments), any other initialized by its value; guarded when its class has a destructor.
cpp.Construction.defaulted
Section titled “cpp.Construction.defaulted”def Construction.defaulted (k : Constructing) (c : StatementContext Cpp.constructs) (env : Env Cpp.constructs) (n : NodeId) (y : String) : CheckResult Cpp.constructs (TypedStmt Cpp.constructs)A member of a class without constructors default-initialized in a constructor: nothing stored, but guarded (the member’s class has a destructor, so it is destroyed if a later member throws, [except.ctor]p3).
cpp.Construction.declaredObject
Section titled “cpp.Construction.declaredObject”def Construction.declaredObject (k : Constructing) (c : StatementContext Cpp.constructs) (env : Env Cpp.constructs) (n : NodeId) (x : DeclId) (name : String) (t : TypeSyntax) (cls : ClassMembers) (i : Option Init) : Option (CheckResult Cpp.constructs (TypedStmt Cpp.constructs))A declaration of an object of a class with constructors (no initializer-list constructor taking its list).
cpp.Construction.listTaken
Section titled “cpp.Construction.listTaken”def Construction.listTaken (g : Globals Cpp.constructs) (s : Signature Cpp.constructs) : Option (String * TypeSyntax)The std::initializer_list<E> instance a member function of the signature s takes as its one parameter after
this (by value or by reference, [dcl.init.list]p2), with E, if that is what it takes.
g holds the declarations of the program.
cpp.Construction.listParameter
Section titled “cpp.Construction.listParameter”def Construction.listParameter (g : Globals Cpp.constructs) (cls : ClassMembers) : Option (String * TypeSyntax)The std::initializer_list<E> instance a class’s initializer-list constructor takes, with E, if it has one.
g holds the declarations of the program, cls is the class.
cpp.Construction.itemFits
Section titled “cpp.Construction.itemFits”def Construction.itemFits (k : Choosing) (g : Globals Cpp.constructs) (env : Env Cpp.constructs) (n : NodeId) (t : Ty Cpp.constructs) (i : Init) : BoolWhether one item of a braced list can initialize an element of type t ([over.ics.list]p6: an initializer-list
function is viable only when every item converts to the element type; narrowing is not part of that, it is an error once
the function is chosen). An item that does not check is left to the declaration of the list, which reports it.
k checks the item and ranks its conversion, g and env are the declarations and the scope it is checked in, n is
the node of the list, i the item.
cpp.Construction.listFits
Section titled “cpp.Construction.listFits”def Construction.listFits (k : Choosing) (g : Globals Cpp.constructs) (env : Env Cpp.constructs) (n : NodeId) (element : TypeSyntax) (xs : List Init) : BoolWhether every item of the braced list xs can initialize an element of the written type element.
k checks the items and ranks their conversions, g and env are the declarations and the scope they are checked in,
n is the node of the list.
cpp.Construction.fromList
Section titled “cpp.Construction.fromList”def Construction.fromList (k : Constructing) (c : StatementContext Cpp.constructs) (env : Env Cpp.constructs) (n : NodeId) (place : Expr) (cls : ClassMembers) (list : String * TypeSyntax) (xs : List Init) (after : List (TypedStmt Cpp.constructs)) : CheckResult Cpp.constructs (TypedStmt Cpp.constructs)An object of the class cls (with an initializer-list constructor taking list) constructed at place from the braced
list’s items xs ([dcl.init.list]p3.6, p5): in a block of its own, the backing array const E[n] initialized from them
(each copy-initialized), then the constructor called with std::initializer_list<E>(array, n), then after; the block’s
end destroys the array. The array and the list object are named for n, the list’s node; k checks the statements in
the context c and the scope env.
cpp.Construction.listFor
Section titled “cpp.Construction.listFor”def Construction.listFor (g : Globals Cpp.constructs) (cls : ClassMembers) (xs : List Init) : Option (String * TypeSyntax)The initializer-list constructor’s list type a braced list with items xs initializes an object of the class cls by
(in the globals g), if any: none for an empty list when the class has a default constructor, which value-initializes
it ([dcl.init.list]p3.4, before p3.6: vector<vector<int>> d = {{4, 1}, {}}’s second element is empty, not built from
a list of none).
cpp.Construction.listAt
Section titled “cpp.Construction.listAt”def Construction.listAt (k : Choosing) (g : Globals Cpp.constructs) (env : Env Cpp.constructs) (n : NodeId) (cls : ClassMembers) (xs : List Init) : Option (String * TypeSyntax)Construction.listFor, the list also viable for the items as checked in the scope env ([over.match.list]p1: when no
initializer-list constructor is viable, the other constructors are tried with the items as arguments: vector<string> v{2, "x"}, string s{name}).
k chooses, g holds the declarations of the program, n is the node of the list, cls the class, xs the items.
cpp.Construction.listed
Section titled “cpp.Construction.listed”def Construction.listed (k : Constructing) (c : StatementContext Cpp.constructs) (env : Env Cpp.constructs) (n : NodeId) (x : DeclId) (name : String) (u : Ty Cpp.constructs) (cls : ClassMembers) (list : String * TypeSyntax) (xs : List Init) : CheckResult Cpp.constructs (TypedStmt Cpp.constructs)C x = {a, b…} (the declaration n of x, shown as name, of type u, items xs) for a class cls with an initializer-list
constructor taking list: x reserved, then constructed from the list (Construction.fromList, with k, c and env) and
marked constructed in the list’s block.
cpp.Construction.directScalar
Section titled “cpp.Construction.directScalar”def Construction.directScalar (k : Constructing) (c : StatementContext Cpp.constructs) (env : Env Cpp.constructs) (n : NodeId) (x : DeclId) (name : String) (t : TypeSyntax) (args : List Expr) : CheckResult Cpp.constructs (TypedStmt Cpp.constructs)T x(args); of a type that is not a class: a scalar’s is its initialization by the one argument (int z(7);,
[dcl.init]p17.8), none is default initialization (as T x;), more is excess elements in scalar initializer (clang’s
words); any other type takes no constructor’s arguments.
cpp.Construction.statement
Section titled “cpp.Construction.statement”def Construction.statement (k : Constructing) (c : StatementContext Cpp.constructs) (env : Env Cpp.constructs) (s : Stmt) : Option (CheckResult Cpp.constructs (TypedStmt Cpp.constructs))C++’s statements that construct objects.
cpp.Construction.defaultDeleted
Section titled “cpp.Construction.defaultDeleted”def Construction.defaultDeleted (g : Globals Cpp.constructs) (t : TypeSyntax) (i : Option Init) : BoolWhether a declaration default-initializes an object (or an array of them) of a class that cannot be ([class.default.ctor]p2: its implicit default constructor deleted, or no constructor callable without arguments).
cpp.Construction.noDefault
Section titled “cpp.Construction.noDefault”def Construction.noDefault (g : Globals Cpp.constructs) (t : TypeSyntax) : RefusalWhy an object of a class cannot be default-initialized.
cpp.Construction.declared
Section titled “cpp.Construction.declared”def Construction.declared (types : TypeExtension Cpp.constructs) (g : Globals Cpp.constructs) (s : Stmt) : Option (DeclId * Ty Cpp.constructs)What a statement of C++ declares: C x(args); declares x.
cpp.Construction.destroying
Section titled “cpp.Construction.destroying”def Construction.destroying (functions : List (CheckedFunction Cpp.constructs)) (t : Ty Cpp.constructs) (pointer : TypedExpr Cpp.constructs) : List (TypedStmt Cpp.constructs)The call of an object’s class’s destructor (given a pointer to it), if the program has one.
cpp.Construction.ending
Section titled “cpp.Construction.ending”def Construction.ending (functions : List (CheckedFunction Cpp.constructs)) (s : State Cpp.constructs) (x : DeclId) (c : Block Cpp.constructs) (unwinding : Bool) : List (TypedStmt Cpp.constructs)What runs before an object ends: its class’s destructor, if the program has one; for a member’s guard, the member’s destructor when an exception leaves the scope, else nothing.