[Objective-C patch]. Amend TransformObjCMessageExpr to handle call

to 'super' of instance/class methods and not assert.
rdar://20350364

llvm-svn: 233642
This commit is contained in:
Fariborz Jahanian 2015-03-30 23:30:24 +00:00
parent 4c30259879
commit a8c2a0b0b2
2 changed files with 61 additions and 0 deletions

View File

@ -2623,6 +2623,31 @@ public:
RBracLoc, Args);
}
/// \brief Build a new Objective-C instance/class message to 'super'.
ExprResult RebuildObjCMessageExpr(SourceLocation SuperLoc,
Selector Sel,
ArrayRef<SourceLocation> SelectorLocs,
ObjCMethodDecl *Method,
SourceLocation LBracLoc,
MultiExprArg Args,
SourceLocation RBracLoc) {
ObjCInterfaceDecl *Class = Method->getClassInterface();
QualType ReceiverTy = SemaRef.Context.getObjCInterfaceType(Class);
return Method->isInstanceMethod() ? SemaRef.BuildInstanceMessage(nullptr,
ReceiverTy,
SuperLoc,
Sel, Method, LBracLoc, SelectorLocs,
RBracLoc, Args)
: SemaRef.BuildClassMessage(nullptr,
ReceiverTy,
SuperLoc,
Sel, Method, LBracLoc, SelectorLocs,
RBracLoc, Args);
}
/// \brief Build a new Objective-C ivar reference expression.
///
/// By default, performs semantic analysis to build the new expression.
@ -10047,6 +10072,19 @@ TreeTransform<Derived>::TransformObjCMessageExpr(ObjCMessageExpr *E) {
Args,
E->getRightLoc());
}
else if (E->getReceiverKind() == ObjCMessageExpr::SuperClass ||
E->getReceiverKind() == ObjCMessageExpr::SuperInstance) {
// Build a new class message send to 'super'.
SmallVector<SourceLocation, 16> SelLocs;
E->getSelectorLocs(SelLocs);
return getDerived().RebuildObjCMessageExpr(E->getSuperLoc(),
E->getSelector(),
SelLocs,
E->getMethodDecl(),
E->getLeftLoc(),
Args,
E->getRightLoc());
}
// Instance message: transform the receiver
assert(E->getReceiverKind() == ObjCMessageExpr::Instance &&

View File

@ -0,0 +1,23 @@
// RUN: %clang_cc1 -fsyntax-only -verify %s
// rdar://20350364
@interface NSObject @end
@interface DBGViewDebuggerSupport : NSObject
+ (void)addViewLayerInfo:(id)view;
- (void)addInstViewLayerInfo:(id)view;
@end
@interface DBGViewDebuggerSupport_iOS : DBGViewDebuggerSupport
@end
@implementation DBGViewDebuggerSupport_iOS
+ (void)addViewLayerInfo:(id)aView; // expected-note {{'aView' declared here}}
{
[super addViewLayerInfo:view]; // expected-error {{use of undeclared identifier 'view'; did you mean 'aView'?}}
}
- (void)addInstViewLayerInfo:(id)aView; // expected-note {{'aView' declared here}}
{
[super addInstViewLayerInfo:view]; // expected-error {{use of undeclared identifier 'view'; did you mean 'aView'?}}
}
@end