diff options
-rw-r--r-- | include/clang/AST/ExprObjC.h | 3 | ||||
-rw-r--r-- | lib/AST/Expr.cpp | 18 |
2 files changed, 20 insertions, 1 deletions
diff --git a/include/clang/AST/ExprObjC.h b/include/clang/AST/ExprObjC.h index aaad04b304..263ba17a02 100644 --- a/include/clang/AST/ExprObjC.h +++ b/include/clang/AST/ExprObjC.h @@ -610,6 +610,9 @@ public: /// sent to. ReceiverKind getReceiverKind() const { return (ReceiverKind)Kind; } + /// \brief Source range of the receiver. + SourceRange getReceiverRange() const; + /// \brief Determine whether this is an instance message to either a /// computed object or to super. bool isInstanceMessage() const { diff --git a/lib/AST/Expr.cpp b/lib/AST/Expr.cpp index 93ebb70442..bb91934669 100644 --- a/lib/AST/Expr.cpp +++ b/lib/AST/Expr.cpp @@ -2330,7 +2330,23 @@ ObjCMessageExpr *ObjCMessageExpr::CreateEmpty(ASTContext &Context, void *Mem = Context.Allocate(Size, llvm::AlignOf<ObjCMessageExpr>::Alignment); return new (Mem) ObjCMessageExpr(EmptyShell(), NumArgs); } - + +SourceRange ObjCMessageExpr::getReceiverRange() const { + switch (getReceiverKind()) { + case Instance: + return getInstanceReceiver()->getSourceRange(); + + case Class: + return getClassReceiverTypeInfo()->getTypeLoc().getSourceRange(); + + case SuperInstance: + case SuperClass: + return getSuperLoc(); + } + + return SourceLocation(); +} + Selector ObjCMessageExpr::getSelector() const { if (HasMethod) return reinterpret_cast<const ObjCMethodDecl *>(SelectorOrMethod) |