This looks like a reasonable refactoring which you can check in independent of everything else if you see no clang test regressions.
- Fariborz > On Nov 23, 2014, at 8:09 AM, AlexDenisov <[email protected]> wrote: > > Finally, the problem is solved. > I’ve found that EmitObjCBoxedExpr uses EmitAnyExpr to handle SubExpr (which > might be treated as a method call' argument), while EmitObjCMessageExpr uses > EmitCallArgs. > To solve the problem I just unified a bit EmitObjCBoxedExpr, so now it also > uses EmitCallArgs. > > Here is the part of the full diff, which illustrates unification of > EmitObjCBoxedExpr and EmitObjCMessageExpr: > diff --git a/include/clang/AST/ExprObjC.h b/include/clang/AST/ExprObjC.h > index 817c0cc..82738da 100644 > --- a/include/clang/AST/ExprObjC.h > +++ b/include/clang/AST/ExprObjC.h > @@ -124,6 +124,15 @@ class ObjCBoxedExpr : public Expr { > > // Iterators > child_range children() { return child_range(&SubExpr, &SubExpr+1); } > + > + typedef ConstExprIterator const_arg_iterator; > + > + const_arg_iterator arg_begin() const { > + return reinterpret_cast<Stmt const * const*>(&SubExpr); > + } > + const_arg_iterator arg_end() const { > + return reinterpret_cast<Stmt const * const*>(&SubExpr + 1); > + } > > friend class ASTStmtReader; > }; > diff --git a/lib/CodeGen/CGObjC.cpp b/lib/CodeGen/CGObjC.cpp > index ca67c4b..d2975b8 100644 > --- a/lib/CodeGen/CGObjC.cpp > +++ b/lib/CodeGen/CGObjC.cpp > @@ -55,12 +55,12 @@ llvm::Value *CodeGenFunction::EmitObjCStringLiteral(const > ObjCStringLiteral *E) > /// EmitObjCBoxedExpr - This routine generates code to call > /// the appropriate expression boxing method. This will either be > -/// one of +[NSNumber numberWith<Type>:], or +[NSString > stringWithUTF8String:]. > +/// one of +[NSNumber numberWith<Type>:], or +[NSString > stringWithUTF8String:], > +/// or [NSValue valueWith<Type>:]. > /// > llvm::Value * > CodeGenFunction::EmitObjCBoxedExpr(const ObjCBoxedExpr *E) { > // Generate the correct selector for this literal's concrete type. > - const Expr *SubExpr = E->getSubExpr(); > // Get the method. > const ObjCMethodDecl *BoxingMethod = E->getBoxingMethod(); > assert(BoxingMethod && "BoxingMethod is null"); > @@ -73,12 +73,9 @@ CodeGenFunction::EmitObjCBoxedExpr(const ObjCBoxedExpr *E) > { > CGObjCRuntime &Runtime = CGM.getObjCRuntime(); > const ObjCInterfaceDecl *ClassDecl = BoxingMethod->getClassInterface(); > llvm::Value *Receiver = Runtime.GetClass(*this, ClassDecl); > - > - const ParmVarDecl *argDecl = *BoxingMethod->param_begin(); > - QualType ArgQT = argDecl->getType().getUnqualifiedType(); > - RValue RV = EmitAnyExpr(SubExpr); > + > CallArgList Args; > - Args.add(RV, ArgQT); > + EmitCallArgs(Args, BoxingMethod, E->arg_begin(), E->arg_end()); > > RValue result = Runtime.GenerateMessageSend( > *this, ReturnValueSlot(), BoxingMethod->getReturnType(), Sel, Receiver, >
_______________________________________________ cfe-commits mailing list [email protected] http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
