aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2011-02-08 02:14:35 +0000
committerDouglas Gregor <dgregor@apple.com>2011-02-08 02:14:35 +0000
commit5e6fcd4ba9cc4cab5a6be0a76bca9d51480ea346 (patch)
tree4e5fc697c1c96ed8bc105e826374cfe7c5dd4a13 /lib
parent68cf1a5a01ba43ed56a8624632fd65e0804430ac (diff)
Sema::MaybeBindToTemporary() shouldn't treat any expression returning
a glvalue as a temporary. Previously, we were enumerating all of the cases that coul return glvalues and might be called with Sema::MaybeBindToTemporary(), but that was gross and we missed the Objective-C property reference case. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@125070 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/Sema/SemaExprCXX.cpp14
1 files changed, 3 insertions, 11 deletions
diff --git a/lib/Sema/SemaExprCXX.cpp b/lib/Sema/SemaExprCXX.cpp
index 81031a54ee..ea1ad51e9d 100644
--- a/lib/Sema/SemaExprCXX.cpp
+++ b/lib/Sema/SemaExprCXX.cpp
@@ -3370,17 +3370,9 @@ ExprResult Sema::MaybeBindToTemporary(Expr *E) {
if (!RT)
return Owned(E);
- // If this is the result of a call or an Objective-C message send expression,
- // our source might actually be a reference, in which case we shouldn't bind.
- if (CallExpr *CE = dyn_cast<CallExpr>(E)) {
- if (CE->getCallReturnType()->isReferenceType())
- return Owned(E);
- } else if (ObjCMessageExpr *ME = dyn_cast<ObjCMessageExpr>(E)) {
- if (const ObjCMethodDecl *MD = ME->getMethodDecl()) {
- if (MD->getResultType()->isReferenceType())
- return Owned(E);
- }
- }
+ // If the result is a glvalue, we shouldn't bind it.
+ if (E->Classify(Context).isGLValue())
+ return Owned(E);
// That should be enough to guarantee that this type is complete.
// If it has a trivial destructor, we can avoid the extra copy.