summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnders Carlsson <andersca@mac.com>2009-08-16 04:11:06 +0000
committerAnders Carlsson <andersca@mac.com>2009-08-16 04:11:06 +0000
commite80ccac2cbd5536246de00814f309d73ad121df4 (patch)
tree99ff9258b0169f95fd744a3925a068fc457bebfb
parent1c83debc36c16b69d7cb79f90e991c64bdfd5447 (diff)
downloadbcm5719-llvm-e80ccac2cbd5536246de00814f309d73ad121df4.tar.gz
bcm5719-llvm-e80ccac2cbd5536246de00814f309d73ad121df4.zip
Call MaybeBindToTemporary for overloaded binary and unary operators.
llvm-svn: 79173
-rw-r--r--clang/lib/AST/Expr.cpp3
-rw-r--r--clang/lib/Sema/SemaOverload.cpp13
-rw-r--r--clang/test/CodeGenCXX/temp-1.cpp16
3 files changed, 25 insertions, 7 deletions
diff --git a/clang/lib/AST/Expr.cpp b/clang/lib/AST/Expr.cpp
index b92ecac6a31..fa5ce9f0478 100644
--- a/clang/lib/AST/Expr.cpp
+++ b/clang/lib/AST/Expr.cpp
@@ -588,6 +588,9 @@ bool Expr::isUnusedResultAWarning(SourceLocation &Loc, SourceRange &R1,
// effects (e.g. a placement new with an uninitialized POD).
case CXXDeleteExprClass:
return false;
+ case CXXBindTemporaryExprClass:
+ return cast<CXXBindTemporaryExpr>(this)
+ ->getSubExpr()->isUnusedResultAWarning(Loc, R1, R2);
case CXXExprWithTemporariesClass:
return cast<CXXExprWithTemporaries>(this)
->getSubExpr()->isUnusedResultAWarning(Loc, R1, R2);
diff --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp
index d4187f2ce1b..6b76ce80d79 100644
--- a/clang/lib/Sema/SemaOverload.cpp
+++ b/clang/lib/Sema/SemaOverload.cpp
@@ -4041,9 +4041,10 @@ Sema::OwningExprResult Sema::CreateOverloadedUnaryOp(SourceLocation OpLoc,
UsualUnaryConversions(FnExpr);
input.release();
- return Owned(new (Context) CXXOperatorCallExpr(Context, Op, FnExpr,
- &Input, 1, ResultTy,
- OpLoc));
+
+ Expr *CE = new (Context) CXXOperatorCallExpr(Context, Op, FnExpr,
+ &Input, 1, ResultTy, OpLoc);
+ return MaybeBindToTemporary(CE);
} else {
// We matched a built-in operator. Convert the arguments, then
// break out so that we will build the appropriate built-in
@@ -4196,9 +4197,9 @@ Sema::CreateOverloadedBinOp(SourceLocation OpLoc,
OpLoc);
UsualUnaryConversions(FnExpr);
- return Owned(new (Context) CXXOperatorCallExpr(Context, Op, FnExpr,
- Args, 2, ResultTy,
- OpLoc));
+ Expr *CE = new (Context) CXXOperatorCallExpr(Context, Op, FnExpr,
+ Args, 2, ResultTy, OpLoc);
+ return MaybeBindToTemporary(CE);
} else {
// We matched a built-in operator. Convert the arguments, then
// break out so that we will build the appropriate built-in
diff --git a/clang/test/CodeGenCXX/temp-1.cpp b/clang/test/CodeGenCXX/temp-1.cpp
index 737bf65b473..19a6acecf28 100644
--- a/clang/test/CodeGenCXX/temp-1.cpp
+++ b/clang/test/CodeGenCXX/temp-1.cpp
@@ -49,9 +49,23 @@ struct D {
};
// 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() {
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();
+}
OpenPOWER on IntegriCloud