@@ -509,23 +509,36 @@ QualType CodeGenFunction::TypeOfSelfObject() {
509
509
return PTy->getPointeeType ();
510
510
}
511
511
512
- RValue CodeGenFunction::EmitObjCSuperPropertyGet (const Expr *Exp,
513
- const Selector &S,
514
- ReturnValueSlot Return) {
515
- llvm::Value *Receiver = LoadObjCSelf ();
516
- const ObjCMethodDecl *OMD = cast<ObjCMethodDecl>(CurFuncDecl);
512
+ LValue
513
+ CodeGenFunction::EmitObjCPropertyRefLValue (const ObjCPropertyRefExpr *E) {
514
+ // This is a special l-value that just issues sends when we load or
515
+ // store through it.
516
+
517
+ // For certain base kinds, we need to emit the base immediately.
518
+ llvm::Value *Base;
519
+ if (E->isSuperReceiver ())
520
+ Base = LoadObjCSelf ();
521
+ else if (E->isClassReceiver ())
522
+ Base = CGM.getObjCRuntime ().GetClass (Builder, E->getClassReceiver ());
523
+ else
524
+ Base = EmitScalarExpr (E->getBase ());
525
+ return LValue::MakePropertyRef (E, Base);
526
+ }
527
+
528
+ static RValue GenerateMessageSendSuper (CodeGenFunction &CGF,
529
+ ReturnValueSlot Return,
530
+ QualType ResultType,
531
+ Selector S,
532
+ llvm::Value *Receiver,
533
+ const CallArgList &CallArgs) {
534
+ const ObjCMethodDecl *OMD = cast<ObjCMethodDecl>(CGF.CurFuncDecl );
517
535
bool isClassMessage = OMD->isClassMethod ();
518
536
bool isCategoryImpl = isa<ObjCCategoryImplDecl>(OMD->getDeclContext ());
519
- return CGM.getObjCRuntime ().GenerateMessageSendSuper (*this ,
520
- Return,
521
- Exp->getType (),
522
- S,
523
- OMD->getClassInterface (),
524
- isCategoryImpl,
525
- Receiver,
526
- isClassMessage,
527
- CallArgList ());
528
-
537
+ return CGF.CGM .getObjCRuntime ()
538
+ .GenerateMessageSendSuper (CGF, Return, ResultType,
539
+ S, OMD->getClassInterface (),
540
+ isCategoryImpl, Receiver,
541
+ isClassMessage, CallArgs);
529
542
}
530
543
531
544
RValue CodeGenFunction::EmitLoadOfPropertyRefLValue (LValue LV,
@@ -543,38 +556,20 @@ RValue CodeGenFunction::EmitLoadOfPropertyRefLValue(LValue LV,
543
556
ResultType = Getter->getResultType (); // with reference!
544
557
}
545
558
559
+ llvm::Value *Receiver = LV.getPropertyRefBaseAddr ();
560
+
561
+ // Accesses to 'super' follow a different code path.
546
562
if (E->isSuperReceiver ())
547
- return EmitObjCSuperPropertyGet (E, S, Return);
563
+ return GenerateMessageSendSuper (*this , Return, ResultType,
564
+ S, Receiver, CallArgList ());
548
565
549
- llvm::Value *Receiver = LV.getPropertyRefBaseAddr ();
550
566
const ObjCInterfaceDecl *ReceiverClass
551
567
= (E->isClassReceiver () ? E->getClassReceiver () : 0 );
552
568
return CGM.getObjCRuntime ().
553
569
GenerateMessageSend (*this , Return, ResultType, S,
554
570
Receiver, CallArgList (), ReceiverClass);
555
571
}
556
572
557
- void CodeGenFunction::EmitObjCSuperPropertySet (const Expr *Exp,
558
- const Selector &S,
559
- RValue Src) {
560
- CallArgList Args;
561
- llvm::Value *Receiver = LoadObjCSelf ();
562
- const ObjCMethodDecl *OMD = cast<ObjCMethodDecl>(CurFuncDecl);
563
- bool isClassMessage = OMD->isClassMethod ();
564
- bool isCategoryImpl = isa<ObjCCategoryImplDecl>(OMD->getDeclContext ());
565
- Args.push_back (std::make_pair (Src, Exp->getType ()));
566
- CGM.getObjCRuntime ().GenerateMessageSendSuper (*this ,
567
- ReturnValueSlot (),
568
- getContext ().VoidTy ,
569
- S,
570
- OMD->getClassInterface (),
571
- isCategoryImpl,
572
- Receiver,
573
- isClassMessage,
574
- Args);
575
- return ;
576
- }
577
-
578
573
void CodeGenFunction::EmitStoreThroughPropertyRefLValue (RValue Src,
579
574
LValue Dst) {
580
575
const ObjCPropertyRefExpr *E = Dst.getPropertyRefExpr ();
@@ -588,20 +583,24 @@ void CodeGenFunction::EmitStoreThroughPropertyRefLValue(RValue Src,
588
583
ArgType = E->getType ();
589
584
}
590
585
586
+ CallArgList Args;
587
+ Args.push_back (std::make_pair (Src, ArgType));
588
+
589
+ llvm::Value *Receiver = Dst.getPropertyRefBaseAddr ();
590
+ QualType ResultType = getContext ().VoidTy ;
591
+
591
592
if (E->isSuperReceiver ()) {
592
- EmitObjCSuperPropertySet (E, S, Src);
593
+ GenerateMessageSendSuper (*this , ReturnValueSlot (),
594
+ ResultType, S, Receiver, Args);
593
595
return ;
594
596
}
595
597
596
- llvm::Value *Receiver = Dst.getPropertyRefBaseAddr ();
597
598
const ObjCInterfaceDecl *ReceiverClass
598
599
= (E->isClassReceiver () ? E->getClassReceiver () : 0 );
599
600
600
- CallArgList Args;
601
- Args.push_back (std::make_pair (Src, ArgType));
602
601
CGM.getObjCRuntime ().GenerateMessageSend (*this , ReturnValueSlot (),
603
- getContext (). VoidTy , S,
604
- Receiver, Args, ReceiverClass);
602
+ ResultType , S, Receiver, Args ,
603
+ ReceiverClass);
605
604
}
606
605
607
606
void CodeGenFunction::EmitObjCForCollectionStmt (const ObjCForCollectionStmt &S){
0 commit comments