[cfe-commits] r108559 - in /cfe/trunk: lib/Sema/SemaExprCXX.cpp test/CodeGenObjCXX/references.mm
Anders Carlsson
andersca at mac.com
Fri Jul 16 14:18:38 PDT 2010
Author: andersca
Date: Fri Jul 16 16:18:37 2010
New Revision: 108559
URL: http://llvm.org/viewvc/llvm-project?rev=108559&view=rev
Log:
When checking whether to bind an expression to a temporary, don't bind Obj-C message send expressions who call methods that return references.
Modified:
cfe/trunk/lib/Sema/SemaExprCXX.cpp
cfe/trunk/test/CodeGenObjCXX/references.mm
Modified: cfe/trunk/lib/Sema/SemaExprCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprCXX.cpp?rev=108559&r1=108558&r2=108559&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExprCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprCXX.cpp Fri Jul 16 16:18:37 2010
@@ -2579,29 +2579,17 @@
if (!RT)
return Owned(E);
- // If this is the result of a call expression, our source might
- // actually be a reference, in which case we shouldn't bind.
+ // 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)) {
- QualType Ty = CE->getCallee()->getType();
- if (const PointerType *PT = Ty->getAs<PointerType>())
- Ty = PT->getPointeeType();
- else if (const BlockPointerType *BPT = Ty->getAs<BlockPointerType>())
- Ty = BPT->getPointeeType();
-
- const FunctionType *FTy = Ty->getAs<FunctionType>();
- if (FTy->getResultType()->isReferenceType())
+ 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);
+ }
}
- else if (ObjCMessageExpr *ME = dyn_cast<ObjCMessageExpr>(E)) {
- QualType Ty = ME->getType();
- if (const PointerType *PT = Ty->getAs<PointerType>())
- Ty = PT->getPointeeType();
- else if (const BlockPointerType *BPT = Ty->getAs<BlockPointerType>())
- Ty = BPT->getPointeeType();
- if (Ty->isReferenceType())
- 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.
Modified: cfe/trunk/test/CodeGenObjCXX/references.mm
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjCXX/references.mm?rev=108559&r1=108558&r2=108559&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenObjCXX/references.mm (original)
+++ cfe/trunk/test/CodeGenObjCXX/references.mm Fri Jul 16 16:18:37 2010
@@ -19,6 +19,7 @@
// CHECK: define void @_Z1fP1B
// CHECK: objc_msgSend to
+// CHECK-NOT: call void @_ZN1AD1Ev
// CHECK: ret void
void f(B* b) {
(void)[b getA];
More information about the cfe-commits
mailing list