Fixes PR5695.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@90702
91177308-0d34-0410-b5e6-
96231b3b80d8
if (ImplicitCastExpr *ICE = dyn_cast<ImplicitCastExpr>(E))
if (ICE->getCastKind() == CastExpr::CK_NoOp)
E = ICE->getSubExpr();
-
- if (isa<CallExpr>(E) || isa<CXXTemporaryObjectExpr>(E))
+
+ if (CallExpr *CE = dyn_cast<CallExpr>(E))
+ Elidable = !CE->getCallReturnType()->isReferenceType();
+ else if (isa<CXXTemporaryObjectExpr>(E))
Elidable = true;
}
--- /dev/null
+// RUN: clang-cc %s -emit-llvm -o - | FileCheck %s
+// PR5695
+
+struct A { A(const A&); ~A(); };
+A& a();
+void b() {
+ A x = a();
+}
+
+// CHECK: call void @_ZN1AC1ERKS_
+// CHECK: call void @_ZN1AD1Ev