copies
本頁內容尚未翻譯。
cpp.Copies.classOf
Section titled “cpp.Copies.classOf”def Copies.classOf (g : Globals Cpp.constructs) (t : Ty Cpp.constructs) : Option ClassMembersThe class of a type, if it is one the program defines.
cpp.ClassMembers.passedByAddress
Section titled “cpp.ClassMembers.passedByAddress”def ClassMembers.passedByAddress (c : ClassMembers) : BoolWhether a class is passed by the address of a copy: it has a copy or move constructor or a destructor.
cpp.ClassMembers.copyDeleted
Section titled “cpp.ClassMembers.copyDeleted”def ClassMembers.copyDeleted (c : ClassMembers) (e : TypedExpr Cpp.constructs) : BoolWhether copying an object of a class from a value is not allowed: the class declares a move and so its implicit copy constructor is deleted, and the value is an lvalue (an rvalue is moved).
cpp.ClassMembers.deletedCopy
Section titled “cpp.ClassMembers.deletedCopy”def ClassMembers.deletedCopy (n : NodeId) (c : ClassMembers) : CheckResult Cpp.constructs (Lifted Cpp.constructs)The rejection of copying an object of a class whose copy constructor is deleted.
cpp.Copies.parameterType
Section titled “cpp.Copies.parameterType”def Copies.parameterType (g : Globals Cpp.constructs) (t : Ty Cpp.constructs) : Ty Cpp.constructsHow a parameter of a type is passed: a class passed by address as passedByAddress, any other as it is.
cpp.Copies.constructorFor
Section titled “cpp.Copies.constructorFor”def Copies.constructorFor (g : Globals Cpp.constructs) (u : Ty Cpp.constructs) (moving : Bool) : Option StringThe constructor a copy of an object of a class is made by, if it has one: the move constructor for an xvalue (or a
value that may be moved from, moving) when the class has one, else the copy constructor.
cpp.Copies.constructorCall
Section titled “cpp.Copies.constructorCall”def Copies.constructorCall (g : Globals Cpp.constructs) (n : NodeId) (f : String) (target : TypedExpr Cpp.constructs) (source : TypedExpr Cpp.constructs) : List (TypedStmt Cpp.constructs)The call at the node n of the copy or move constructor f (its signature among the globals g) on the object
at target from the object at source: the parameters after those take their defaults ([class.copy.ctor]p1), whose
statements come first.
cpp.Copies.argument
Section titled “cpp.Copies.argument”def Copies.argument (g : Globals Cpp.constructs) (n : NodeId) (u : Ty Cpp.constructs) (e : TypedExpr Cpp.constructs) : Lifted Cpp.constructsAn argument for a parameter passed by address: the address of the caller’s copy (made by the move constructor for an xvalue, else the copy constructor, else bit for bit), or of the temporary itself.
cpp.Copies.conversion
Section titled “cpp.Copies.conversion”def Copies.conversion (g : Globals Cpp.constructs) (n : NodeId) (t : Ty Cpp.constructs) (e : TypedExpr Cpp.constructs) : Option (CheckResult Cpp.constructs (Lifted Cpp.constructs))C++’s conversion for a parameter passed by address.
cpp.Copies.assignmentName
Section titled “cpp.Copies.assignmentName”def Copies.assignmentName (op : Option BinaryOp) : StringThe member function an assignment calls on an object of a class: operator=, or operator+= and the others for a
compound assignment.
cpp.Copies.keptRight
Section titled “cpp.Copies.keptRight”def Copies.keptRight (checker : Checker Cpp.constructs) (g : Globals Cpp.constructs) (env : Env Cpp.constructs) (n : NodeId) (rhs : Expr) (l : Lifted Cpp.constructs) : Option KeptThe right operand rhs of an assignment to an object of a class, checked by checker with the globals g in the
scope env, kept before the left one (Classes.kept, at the node n), when the left one, checked as l, has
statements of its own and the right one makes an access: C++17 sequences the right operand before the left
([expr.ass]p1), and an operator function’s operands as the built-in operator’s ([over.match.oper]p2). Else none: the
operands as written.
cpp.Copies.assignment
Section titled “cpp.Copies.assignment”def Copies.assignment (checker : Checker Cpp.constructs) (g : Globals Cpp.constructs) (env : Env Cpp.constructs) (asLvalue : Bool) (e : Expr) : Option (CheckResult Cpp.constructs (Lifted Cpp.constructs))An assignment to an object of a class with a copy assignment operator (or compound, += and the others): a call
of it, a.operator=(b) ([over.ass]), an lvalue when the operator returns a reference (&(a = b)); its access and
constness are checked as a member function call’s. The right operand goes first (Copies.keptRight).
cpp.Copies.isGlobal
Section titled “cpp.Copies.isGlobal”def Copies.isGlobal (g : Globals Cpp.constructs) (x : DeclId) : BoolWhether a variable is a global one.
cpp.Copies.otherReturned
Section titled “cpp.Copies.otherReturned”def Copies.otherReturned (y : DeclId) (s : Stmt) : BoolWhether a statement is a return of something other than the variable y.
cpp.Copies.declares
Section titled “cpp.Copies.declares”def Copies.declares (y : DeclId) (s : Stmt) : BoolWhether a statement declares the variable y.
cpp.Copies.after
Section titled “cpp.Copies.after”def Copies.after (y : DeclId) (ss : List Stmt) : Option (List Stmt)The statements after the declaration of y among statements (its scope in their block), if they declare it.
cpp.Copies.otherInScope
Section titled “cpp.Copies.otherInScope”def Copies.otherInScope (y : DeclId) (s : Stmt) : BoolWhether a statement is a block declaring y in which a return after the declaration returns something else.
cpp.Copies.ofLibrary
Section titled “cpp.Copies.ofLibrary”def Copies.ofLibrary (g : Globals Cpp.constructs) (x : String) : BoolWhether a class is a library’s: std’s, or one a library written in C++ defines (a function of it is the library’s,
CppTables.library). A library’s copies, moves and destruction write nothing the program sees (the libraries keep to
that: the Arduino String’s are malloc and free), so whether a return elides one does not change the output.
cpp.Copies.onlyReturned
Section titled “cpp.Copies.onlyReturned”def Copies.onlyReturned (g : Globals Cpp.constructs) (y : DeclId) : BoolWhether every return in the scope of the variable y returns it (when clang elides its copy, as its NRVO does: another return in the function, outside y’s scope, does not matter).
cpp.Copies.returnValue
Section titled “cpp.Copies.returnValue”def Copies.returnValue (assign : Globals Cpp.constructs -> NodeId -> Ty Cpp.constructs -> TypedExpr Cpp.constructs -> CheckResult Cpp.constructs (Lifted Cpp.constructs)) (checker : Checker Cpp.constructs) (c : StatementContext Cpp.constructs) (env : Env Cpp.constructs) (n : NodeId) (t : Ty Cpp.constructs) (x : Expr) : Option (CheckResult Cpp.constructs (TypedStmt Cpp.constructs))How a value of a class passed by address is returned ([stmt.return], [class.copy.elision]): a temporary (a call’s result) is handed over as it is; a local object every return in its scope returns is handed over without a copy, as clang does, noting that the standard also allows copying it; anything else (a parameter, a member, a global, one of several local objects returned) is copied first by the copy constructor (else bit for bit) and the copy handed over; a local object or a parameter named alone is moved instead when the class has a move constructor ([class.copy.elision]p3), as is an xvalue. Handing over keeps the object from being destroyed when its scope ends: the caller has it now.