forked from OSchip/llvm-project
Rearrange some checks to avoid call to isCopyConstructor() and clarify path
taken for non-trivial constructors. llvm-svn: 95457
This commit is contained in:
parent
5638c36efd
commit
ca972cd1f1
|
@ -1227,20 +1227,22 @@ CodeGenFunction::EmitCXXConstructorCall(const CXXConstructorDecl *D,
|
||||||
llvm::Value *This,
|
llvm::Value *This,
|
||||||
CallExpr::const_arg_iterator ArgBeg,
|
CallExpr::const_arg_iterator ArgBeg,
|
||||||
CallExpr::const_arg_iterator ArgEnd) {
|
CallExpr::const_arg_iterator ArgEnd) {
|
||||||
if (D->isCopyConstructor()) {
|
if (D->isTrivial()) {
|
||||||
const CXXRecordDecl *ClassDecl = cast<CXXRecordDecl>(D->getDeclContext());
|
if (ArgBeg == ArgEnd) {
|
||||||
if (ClassDecl->hasTrivialCopyConstructor()) {
|
// Trivial default constructor, no codegen required.
|
||||||
assert(!ClassDecl->hasUserDeclaredCopyConstructor() &&
|
assert(D->isDefaultConstructor() &&
|
||||||
"EmitCXXConstructorCall - user declared copy constructor");
|
"trivial 0-arg ctor not a default ctor");
|
||||||
const Expr *E = (*ArgBeg);
|
|
||||||
QualType Ty = E->getType();
|
|
||||||
llvm::Value *Src = EmitLValue(E).getAddress();
|
|
||||||
EmitAggregateCopy(This, Src, Ty);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else if (D->isTrivial()) {
|
|
||||||
// FIXME: Track down why we're trying to generate calls to the trivial
|
assert(ArgBeg + 1 == ArgEnd && "unexpected argcount for trivial ctor");
|
||||||
// default constructor!
|
assert(D->isCopyConstructor() && "trivial 1-arg ctor not a copy ctor");
|
||||||
|
|
||||||
|
const CXXRecordDecl *ClassDecl = cast<CXXRecordDecl>(D->getDeclContext());
|
||||||
|
const Expr *E = (*ArgBeg);
|
||||||
|
QualType Ty = E->getType();
|
||||||
|
llvm::Value *Src = EmitLValue(E).getAddress();
|
||||||
|
EmitAggregateCopy(This, Src, Ty);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue