Changeset View
Changeset View
Standalone View
Standalone View
clang/lib/Sema/SemaDeclCXX.cpp
- This file is larger than 256 KB, so syntax highlighting is disabled by default.
Show First 20 Lines • Show All 15,294 Lines • ▼ Show 20 Lines | Sema::BuildCXXConstructExpr(SourceLocation ConstructLoc, QualType DeclInitType, | ||||
// copy/move constructor and/or destructor for the object have | // copy/move constructor and/or destructor for the object have | ||||
// side effects. [...] | // side effects. [...] | ||||
// - when a temporary class object that has not been bound to a | // - when a temporary class object that has not been bound to a | ||||
// reference (12.2) would be copied/moved to a class object | // reference (12.2) would be copied/moved to a class object | ||||
// with the same cv-unqualified type, the copy/move operation | // with the same cv-unqualified type, the copy/move operation | ||||
// can be omitted by constructing the temporary object | // can be omitted by constructing the temporary object | ||||
// directly into the target of the omitted copy/move | // directly into the target of the omitted copy/move | ||||
if (ConstructKind == CXXConstructExpr::CK_Complete && Constructor && | if (ConstructKind == CXXConstructExpr::CK_Complete && Constructor && | ||||
// FIXME: These two conditions are wrong: | |||||
// * Converting constructors should also be allowed | |||||
// * It can have more than one real argument, provided | |||||
// they are default ones from the second on. | |||||
// But to fix this, the logic that digs down into a CXXConstructExpr | |||||
// to find the source object needs to handle it. | |||||
// Right now it assumes the source object is passed directly as the | |||||
// first argument. | |||||
Constructor->isCopyOrMoveConstructor() && hasOneRealArgument(ExprArgs)) { | Constructor->isCopyOrMoveConstructor() && hasOneRealArgument(ExprArgs)) { | ||||
Expr *SubExpr = ExprArgs[0]; | Expr *SubExpr = ExprArgs[0]; | ||||
Elidable = SubExpr->isTemporaryObject( | Elidable = SubExpr->isTemporaryObject( | ||||
Context, cast<CXXRecordDecl>(FoundDecl->getDeclContext())); | Context, cast<CXXRecordDecl>(FoundDecl->getDeclContext())); | ||||
} | } | ||||
return BuildCXXConstructExpr(ConstructLoc, DeclInitType, | return BuildCXXConstructExpr(ConstructLoc, DeclInitType, | ||||
FoundDecl, Constructor, | FoundDecl, Constructor, | ||||
▲ Show 20 Lines • Show All 2,860 Lines • Show Last 20 Lines |