forked from OSchip/llvm-project
Make copy constructor elimination work in more cases; the case in question
here affects clang-on-clang. llvm-svn: 92151
This commit is contained in:
parent
dd5044ac55
commit
fddc26cc64
|
@ -590,6 +590,9 @@ CodeGenFunction::EmitCXXConstructExpr(llvm::Value *Dest,
|
|||
Arg = ICE->getSubExpr();
|
||||
}
|
||||
|
||||
if (const CXXFunctionalCastExpr *FCE = dyn_cast<CXXFunctionalCastExpr>(Arg))
|
||||
Arg = FCE->getSubExpr();
|
||||
|
||||
if (const CXXBindTemporaryExpr *BindExpr =
|
||||
dyn_cast<CXXBindTemporaryExpr>(Arg))
|
||||
Arg = BindExpr->getSubExpr();
|
||||
|
|
|
@ -3793,6 +3793,8 @@ Sema::BuildCXXConstructExpr(SourceLocation ConstructLoc, QualType DeclInitType,
|
|||
if (ImplicitCastExpr *ICE = dyn_cast<ImplicitCastExpr>(E))
|
||||
if (ICE->getCastKind() == CastExpr::CK_NoOp)
|
||||
E = ICE->getSubExpr();
|
||||
if (CXXFunctionalCastExpr *FCE = dyn_cast<CXXFunctionalCastExpr>(E))
|
||||
E = FCE->getSubExpr();
|
||||
while (CXXBindTemporaryExpr *BE = dyn_cast<CXXBindTemporaryExpr>(E))
|
||||
E = BE->getSubExpr();
|
||||
if (ImplicitCastExpr *ICE = dyn_cast<ImplicitCastExpr>(E))
|
||||
|
@ -3803,6 +3805,8 @@ Sema::BuildCXXConstructExpr(SourceLocation ConstructLoc, QualType DeclInitType,
|
|||
Elidable = !CE->getCallReturnType()->isReferenceType();
|
||||
else if (isa<CXXTemporaryObjectExpr>(E))
|
||||
Elidable = true;
|
||||
else if (isa<CXXConstructExpr>(E))
|
||||
Elidable = true;
|
||||
}
|
||||
|
||||
return BuildCXXConstructExpr(ConstructLoc, DeclInitType, Constructor,
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
// RUN: %clang_cc1 -emit-llvm -o - %s | FileCheck %s
|
||||
|
||||
struct A { int x; A(int); ~A(); };
|
||||
A f() { return A(0); }
|
||||
// CHECK: define void @_Z1fv
|
||||
// CHECK: call void @_ZN1AC1Ei
|
||||
// CHECK-NEXT: ret void
|
Loading…
Reference in New Issue