diff options
Diffstat (limited to 'clang/lib/CodeGen')
| -rw-r--r-- | clang/lib/CodeGen/CGExprScalar.cpp | 4 | ||||
| -rw-r--r-- | clang/lib/CodeGen/CGObjC.cpp | 38 | ||||
| -rw-r--r-- | clang/lib/CodeGen/CodeGenFunction.h | 2 | 
3 files changed, 22 insertions, 22 deletions
| diff --git a/clang/lib/CodeGen/CGExprScalar.cpp b/clang/lib/CodeGen/CGExprScalar.cpp index 18891f7492a..734531f724b 100644 --- a/clang/lib/CodeGen/CGExprScalar.cpp +++ b/clang/lib/CodeGen/CGExprScalar.cpp @@ -498,8 +498,8 @@ public:    Value *VisitObjCStringLiteral(const ObjCStringLiteral *E) {      return CGF.EmitObjCStringLiteral(E);    } -  Value *VisitObjCNumericLiteral(ObjCNumericLiteral *E) { -    return CGF.EmitObjCNumericLiteral(E); +  Value *VisitObjCBoxedExpr(ObjCBoxedExpr *E) { +    return CGF.EmitObjCBoxedExpr(E);    }    Value *VisitObjCArrayLiteral(ObjCArrayLiteral *E) {      return CGF.EmitObjCArrayLiteral(E); diff --git a/clang/lib/CodeGen/CGObjC.cpp b/clang/lib/CodeGen/CGObjC.cpp index d0aa0f5567a..fc274a93a8a 100644 --- a/clang/lib/CodeGen/CGObjC.cpp +++ b/clang/lib/CodeGen/CGObjC.cpp @@ -51,36 +51,36 @@ llvm::Value *CodeGenFunction::EmitObjCStringLiteral(const ObjCStringLiteral *E)    return llvm::ConstantExpr::getBitCast(C, ConvertType(E->getType()));  } -/// EmitObjCNumericLiteral - This routine generates code for -/// the appropriate +[NSNumber numberWith<Type>:] method. +/// EmitObjCBoxedExpr - This routine generates code to call +/// the appropriate expression boxing method. This will either be +/// one of +[NSNumber numberWith<Type>:], or +[NSString stringWithUTF8String:].  ///  llvm::Value * -CodeGenFunction::EmitObjCNumericLiteral(const ObjCNumericLiteral *E) { +CodeGenFunction::EmitObjCBoxedExpr(const ObjCBoxedExpr *E) {    // Generate the correct selector for this literal's concrete type. -  const Expr *NL = E->getNumber(); +  const Expr *SubExpr = E->getSubExpr();    // Get the method. -  const ObjCMethodDecl *Method = E->getObjCNumericLiteralMethod(); -  assert(Method && "NSNumber method is null"); -  Selector Sel = Method->getSelector(); +  const ObjCMethodDecl *BoxingMethod = E->getBoxingMethod(); +  assert(BoxingMethod && "BoxingMethod is null"); +  assert(BoxingMethod->isClassMethod() && "BoxingMethod must be a class method"); +  Selector Sel = BoxingMethod->getSelector();    // Generate a reference to the class pointer, which will be the receiver. -  QualType ResultType = E->getType(); // should be NSNumber * -  const ObjCObjectPointerType *InterfacePointerType =  -    ResultType->getAsObjCInterfacePointerType(); -  ObjCInterfaceDecl *NSNumberDecl =  -    InterfacePointerType->getObjectType()->getInterface(); +  // Assumes that the method was introduced in the class that should be +  // messaged (avoids pulling it out of the result type).    CGObjCRuntime &Runtime = CGM.getObjCRuntime(); -  llvm::Value *Receiver = Runtime.GetClass(Builder, NSNumberDecl); - -  const ParmVarDecl *argDecl = *Method->param_begin(); +  const ObjCInterfaceDecl *ClassDecl = BoxingMethod->getClassInterface(); +  llvm::Value *Receiver = Runtime.GetClass(Builder, ClassDecl); +   +  const ParmVarDecl *argDecl = *BoxingMethod->param_begin();    QualType ArgQT = argDecl->getType().getUnqualifiedType(); -  RValue RV = EmitAnyExpr(NL); +  RValue RV = EmitAnyExpr(SubExpr);    CallArgList Args;    Args.add(RV, ArgQT); - +      RValue result = Runtime.GenerateMessageSend(*this, ReturnValueSlot(),  -                                              ResultType, Sel, Receiver, Args,  -                                              NSNumberDecl, Method); +                                              BoxingMethod->getResultType(), Sel, Receiver, Args,  +                                              ClassDecl, BoxingMethod);    return Builder.CreateBitCast(result.getScalarVal(),                                  ConvertType(E->getType()));  } diff --git a/clang/lib/CodeGen/CodeGenFunction.h b/clang/lib/CodeGen/CodeGenFunction.h index 83f1e2df9f4..001a3710020 100644 --- a/clang/lib/CodeGen/CodeGenFunction.h +++ b/clang/lib/CodeGen/CodeGenFunction.h @@ -2264,7 +2264,7 @@ public:    llvm::Value *EmitObjCProtocolExpr(const ObjCProtocolExpr *E);    llvm::Value *EmitObjCStringLiteral(const ObjCStringLiteral *E); -  llvm::Value *EmitObjCNumericLiteral(const ObjCNumericLiteral *E); +  llvm::Value *EmitObjCBoxedExpr(const ObjCBoxedExpr *E);    llvm::Value *EmitObjCArrayLiteral(const ObjCArrayLiteral *E);    llvm::Value *EmitObjCDictionaryLiteral(const ObjCDictionaryLiteral *E);    llvm::Value *EmitObjCCollectionLiteral(const Expr *E, | 

