r233642 - [Objective-C patch]. Amend TransformObjCMessageExpr to handle call
Fariborz Jahanian
fjahanian at apple.com
Mon Mar 30 16:30:24 PDT 2015
Author: fjahanian
Date: Mon Mar 30 18:30:24 2015
New Revision: 233642
URL: http://llvm.org/viewvc/llvm-project?rev=233642&view=rev
Log:
[Objective-C patch]. Amend TransformObjCMessageExpr to handle call
to 'super' of instance/class methods and not assert.
rdar://20350364
Added:
cfe/trunk/test/SemaObjC/undef-arg-super-method-call.m
Modified:
cfe/trunk/lib/Sema/TreeTransform.h
Modified: cfe/trunk/lib/Sema/TreeTransform.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/TreeTransform.h?rev=233642&r1=233641&r2=233642&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/TreeTransform.h (original)
+++ cfe/trunk/lib/Sema/TreeTransform.h Mon Mar 30 18:30:24 2015
@@ -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.
@@ -10043,6 +10068,19 @@ TreeTransform<Derived>::TransformObjCMes
E->getSelector(),
SelLocs,
E->getMethodDecl(),
+ E->getLeftLoc(),
+ 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());
Added: cfe/trunk/test/SemaObjC/undef-arg-super-method-call.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/undef-arg-super-method-call.m?rev=233642&view=auto
==============================================================================
--- cfe/trunk/test/SemaObjC/undef-arg-super-method-call.m (added)
+++ cfe/trunk/test/SemaObjC/undef-arg-super-method-call.m Mon Mar 30 18:30:24 2015
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// rdar://20350364
+
+ at interface NSObject @end
+
+ at interface DBGViewDebuggerSupport : NSObject
++ (void)addViewLayerInfo:(id)view;
+- (void)addInstViewLayerInfo:(id)view;
+ at end
+
+ at interface DBGViewDebuggerSupport_iOS : DBGViewDebuggerSupport
+ at end
+
+ at 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'?}}
+}
+ at end
More information about the cfe-commits
mailing list