On Fri, Oct 26, 2012 at 5:43 PM, Rafael Espindola <[email protected]> wrote: > Author: rafael > Date: Fri Oct 26 19:43:14 2012 > New Revision: 166849 > > URL: http://llvm.org/viewvc/llvm-project?rev=166849&view=rev > Log: > Refactor some code into a new findMaterializedTemporary function. > > Modified: > cfe/trunk/lib/CodeGen/CGExpr.cpp > > Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=166849&r1=166848&r2=166849&view=diff > ============================================================================== > --- cfe/trunk/lib/CodeGen/CGExpr.cpp (original) > +++ cfe/trunk/lib/CodeGen/CGExpr.cpp Fri Oct 26 19:43:14 2012 > @@ -228,6 +228,27 @@ > } > > static const Expr * > +findMaterializedTemporary(const Expr *E, const MaterializeTemporaryExpr > *&MTE) { > + // Look through single-element init lists that claim to be lvalues. They're > + // just syntactic wrappers in this case. > + if (const InitListExpr *ILE = dyn_cast<InitListExpr>(E)) { > + if (ILE->getNumInits() == 1 && ILE->isGLValue()) > + E = ILE->getInit(0); > + } > + > + // Look through expressions for materialized temporaries (for now). > + if (const MaterializeTemporaryExpr *M > + = dyn_cast<MaterializeTemporaryExpr>(E)) { > + MTE = M; > + E = M->GetTemporaryExpr(); > + } > + > + if (const CXXDefaultArgExpr *DAE = dyn_cast<CXXDefaultArgExpr>(E)) > + E = DAE->getExpr(); > + return E; > +} > + > +static const Expr * > skipRValueSubobjectAdjustments(const Expr *E, > SmallVectorImpl<SubobjectAdjustment> > &Adjustments) { > while (true) { > @@ -279,32 +300,18 @@ > const CXXDestructorDecl *&ReferenceTemporaryDtor, > QualType &ObjCARCReferenceLifetimeType, > const NamedDecl *InitializedDecl) { > - // Look through single-element init lists that claim to be lvalues. They're > - // just syntactic wrappers in this case. > - if (const InitListExpr *ILE = dyn_cast<InitListExpr>(E)) { > - if (ILE->getNumInits() == 1 && ILE->isGLValue()) > - E = ILE->getInit(0); > - } > + const MaterializeTemporaryExpr *M = NULL; > + E = findMaterializedTemporary(E, M); > + // Objective-C++ ARC: > + // If we are binding a reference to a temporary that has ownership, we > + // need to perform retain/release operations on the temporary. > + if (M && CGF.getContext().getLangOpts().ObjCAutoRefCount && > + M->getType()->isObjCLifetimeType() && > + (M->getType().getObjCLifetime() == Qualifiers::OCL_Strong || > + M->getType().getObjCLifetime() == Qualifiers::OCL_Weak || > + M->getType().getObjCLifetime() == Qualifiers::OCL_Autoreleasing)) > + ObjCARCReferenceLifetimeType = M->getType(); > > - // Look through expressions for materialized temporaries (for now). > - if (const MaterializeTemporaryExpr *M > - = > dyn_cast<MaterializeTemporaryExpr>(E)) { > - // Objective-C++ ARC: > - // If we are binding a reference to a temporary that has ownership, we > - // need to perform retain/release operations on the temporary. > - if (CGF.getContext().getLangOpts().ObjCAutoRefCount && > - E->getType()->isObjCLifetimeType() && > - (E->getType().getObjCLifetime() == Qualifiers::OCL_Strong || > - E->getType().getObjCLifetime() == Qualifiers::OCL_Weak || > - E->getType().getObjCLifetime() == Qualifiers::OCL_Autoreleasing)) > - ObjCARCReferenceLifetimeType = E->getType(); > - > - E = M->GetTemporaryExpr(); > - } > - > - if (const CXXDefaultArgExpr *DAE = dyn_cast<CXXDefaultArgExpr>(E)) > - E = DAE->getExpr(); > -
This old and new versions aren't precisely equivalent; is that intentional? -Eli _______________________________________________ cfe-commits mailing list [email protected] http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
