@@ -596,83 +596,43 @@ Sema::OwningExprResult Sema::ActOnSuperMessage(Scope *S,
596
596
MultiExprArg Args) {
597
597
// Determine whether we are inside a method or not.
598
598
ObjCMethodDecl *Method = getCurMethodDecl ();
599
- if (Method) {
600
- ObjCInterfaceDecl *Class = Method->getClassInterface ();
601
- if (!Class) {
602
- Diag (SuperLoc, diag::error_no_super_class_message)
603
- << Method->getDeclName ();
604
- return ExprError ();
605
- }
606
-
607
- if (ObjCInterfaceDecl *Super = Class->getSuperClass ()) {
608
- // We are in a method whose class has a superclass, so 'super'
609
- // is acting as a keyword.
610
- if (Method->isInstanceMethod ()) {
611
- // Since we are in an instance method, this is an instance
612
- // message to the superclass instance.
613
- QualType SuperTy = Context.getObjCInterfaceType (Super);
614
- SuperTy = Context.getObjCObjectPointerType (SuperTy);
615
- return BuildInstanceMessage (ExprArg (*this ), SuperTy, SuperLoc,
616
- Sel, LBracLoc, SelectorLoc, RBracLoc,
617
- move (Args));
618
- }
619
-
620
- // Since we are in a class method, this is a class message to
621
- // the superclass.
622
- return BuildClassMessage (/* ReceiverTypeInfo=*/ 0 ,
623
- Context.getObjCInterfaceType (Super),
624
- SuperLoc, Sel, LBracLoc, SelectorLoc,
625
- RBracLoc, move (Args));
626
- }
599
+ if (!Method) {
600
+ Diag (SuperLoc, diag::err_invalid_receiver_to_message_super);
601
+ return ExprError ();
602
+ }
627
603
628
- // The current class does not have a superclass.
629
- Diag (SuperLoc, diag::error_no_super_class) << Class->getIdentifier ();
604
+ ObjCInterfaceDecl *Class = Method->getClassInterface ();
605
+ if (!Class) {
606
+ Diag (SuperLoc, diag::error_no_super_class_message)
607
+ << Method->getDeclName ();
630
608
return ExprError ();
631
609
}
632
610
633
- Diag (SuperLoc, diag::err_invalid_receiver_to_message_super);
634
- return ExprError ();
635
-
636
- #if 0
637
- // We are not inside a method, or the method is in a class that has
638
- // no superclass, so perform normal name lookup on "super".
639
- IdentifierInfo &SuperId = Context.Idents.get("super");
640
- NamedDecl *Super = LookupSingleName(S, &SuperId, SuperLoc,
641
- LookupOrdinaryName);
611
+ ObjCInterfaceDecl *Super = Class->getSuperClass ();
642
612
if (!Super) {
643
- Diag(SuperLoc, diag::err_undeclared_var_use) << &SuperId;
613
+ // The current class does not have a superclass.
614
+ Diag (SuperLoc, diag::error_no_super_class) << Class->getIdentifier ();
644
615
return ExprError ();
645
616
}
646
617
647
- if (isa<TypeDecl>(Super) || isa<ObjCInterfaceDecl>(Super)) {
648
- // Name lookup found a type named 'super'; create a class message
649
- // sending to it.
650
- QualType SuperType =
651
- isa<TypeDecl>(Super)? Context.getTypeDeclType(cast<TypeDecl>(Super))
652
- : Context.getObjCInterfaceType(cast<ObjCInterfaceDecl>(Super));
653
- TypeSourceInfo *SuperTypeInfo
654
- = Context.getTrivialTypeSourceInfo(SuperType, SuperLoc);
655
- return BuildClassMessage(SuperTypeInfo, SuperType,
656
- /*SuperLoc=*/SourceLocation(),
657
- Sel, LBracLoc, SelectorLoc, RBracLoc,
658
- move(Args));
618
+ // We are in a method whose class has a superclass, so 'super'
619
+ // is acting as a keyword.
620
+ if (Method->isInstanceMethod ()) {
621
+ // Since we are in an instance method, this is an instance
622
+ // message to the superclass instance.
623
+ QualType SuperTy = Context.getObjCInterfaceType (Super);
624
+ SuperTy = Context.getObjCObjectPointerType (SuperTy);
625
+ return BuildInstanceMessage (ExprArg (*this ), SuperTy, SuperLoc,
626
+ Sel, LBracLoc, SelectorLoc, RBracLoc,
627
+ move (Args));
659
628
}
660
-
661
- // Assume that "super" is the name of a value of some
662
- // sort. Type-check it as an id-expression.
663
- CXXScopeSpec SS;
664
- UnqualifiedId Id;
665
- Id.setIdentifier(&SuperId, SuperLoc);
666
- OwningExprResult Receiver = ActOnIdExpression(S, SS, Id, false, false);
667
- if (Receiver.isInvalid() || !Receiver.get())
668
- return ExprError();
669
-
670
- Expr *ReceiverExpr = static_cast<Expr *>(Receiver.get());
671
- return BuildInstanceMessage(move(Receiver), ReceiverExpr->getType(),
672
- /*SuperLoc=*/SourceLocation(),
673
- Sel, LBracLoc, SelectorLoc, RBracLoc,
674
- move(Args));
675
- #endif
629
+
630
+ // Since we are in a class method, this is a class message to
631
+ // the superclass.
632
+ return BuildClassMessage (/* ReceiverTypeInfo=*/ 0 ,
633
+ Context.getObjCInterfaceType (Super),
634
+ SuperLoc, Sel, LBracLoc, SelectorLoc,
635
+ RBracLoc, move (Args));
676
636
}
677
637
678
638
// / \brief Build an Objective-C class message expression.
0 commit comments