зеркало из https://github.com/microsoft/clang-1.git
Call MaybeBindToTemporary for overloaded binary and unary operators.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@79173 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Родитель
a303f9eab9
Коммит
2d46eb21eb
|
@ -588,6 +588,9 @@ bool Expr::isUnusedResultAWarning(SourceLocation &Loc, SourceRange &R1,
|
||||||
// effects (e.g. a placement new with an uninitialized POD).
|
// effects (e.g. a placement new with an uninitialized POD).
|
||||||
case CXXDeleteExprClass:
|
case CXXDeleteExprClass:
|
||||||
return false;
|
return false;
|
||||||
|
case CXXBindTemporaryExprClass:
|
||||||
|
return cast<CXXBindTemporaryExpr>(this)
|
||||||
|
->getSubExpr()->isUnusedResultAWarning(Loc, R1, R2);
|
||||||
case CXXExprWithTemporariesClass:
|
case CXXExprWithTemporariesClass:
|
||||||
return cast<CXXExprWithTemporaries>(this)
|
return cast<CXXExprWithTemporaries>(this)
|
||||||
->getSubExpr()->isUnusedResultAWarning(Loc, R1, R2);
|
->getSubExpr()->isUnusedResultAWarning(Loc, R1, R2);
|
||||||
|
|
|
@ -4041,9 +4041,10 @@ Sema::OwningExprResult Sema::CreateOverloadedUnaryOp(SourceLocation OpLoc,
|
||||||
UsualUnaryConversions(FnExpr);
|
UsualUnaryConversions(FnExpr);
|
||||||
|
|
||||||
input.release();
|
input.release();
|
||||||
return Owned(new (Context) CXXOperatorCallExpr(Context, Op, FnExpr,
|
|
||||||
&Input, 1, ResultTy,
|
Expr *CE = new (Context) CXXOperatorCallExpr(Context, Op, FnExpr,
|
||||||
OpLoc));
|
&Input, 1, ResultTy, OpLoc);
|
||||||
|
return MaybeBindToTemporary(CE);
|
||||||
} else {
|
} else {
|
||||||
// We matched a built-in operator. Convert the arguments, then
|
// We matched a built-in operator. Convert the arguments, then
|
||||||
// break out so that we will build the appropriate built-in
|
// break out so that we will build the appropriate built-in
|
||||||
|
@ -4196,9 +4197,9 @@ Sema::CreateOverloadedBinOp(SourceLocation OpLoc,
|
||||||
OpLoc);
|
OpLoc);
|
||||||
UsualUnaryConversions(FnExpr);
|
UsualUnaryConversions(FnExpr);
|
||||||
|
|
||||||
return Owned(new (Context) CXXOperatorCallExpr(Context, Op, FnExpr,
|
Expr *CE = new (Context) CXXOperatorCallExpr(Context, Op, FnExpr,
|
||||||
Args, 2, ResultTy,
|
Args, 2, ResultTy, OpLoc);
|
||||||
OpLoc));
|
return MaybeBindToTemporary(CE);
|
||||||
} else {
|
} else {
|
||||||
// We matched a built-in operator. Convert the arguments, then
|
// We matched a built-in operator. Convert the arguments, then
|
||||||
// break out so that we will build the appropriate built-in
|
// break out so that we will build the appropriate built-in
|
||||||
|
|
|
@ -49,9 +49,23 @@ struct D {
|
||||||
};
|
};
|
||||||
|
|
||||||
// RUN: grep "call void @_ZN1DC1Ev" %t | count 1 &&
|
// RUN: grep "call void @_ZN1DC1Ev" %t | count 1 &&
|
||||||
// RUN: grep "call void @_ZN1DD1Ev" %t | count 2
|
// RUN: grep "call void @_ZN1DD1Ev" %t | count 2 &&
|
||||||
void f4() {
|
void f4() {
|
||||||
D()();
|
D()();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Overloaded operators
|
||||||
|
struct E {
|
||||||
|
E();
|
||||||
|
~E();
|
||||||
|
E operator+(const E&);
|
||||||
|
E operator!();
|
||||||
|
};
|
||||||
|
|
||||||
|
// RUN: grep "call void @_ZN1EC1Ev" %t | count 3 &&
|
||||||
|
// RUN: grep "call void @_ZN1ED1Ev" %t | count 5
|
||||||
|
void f5() {
|
||||||
|
E() + E();
|
||||||
|
!E();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче