From 17e588020a355892add66fcec831ffec647518da Mon Sep 17 00:00:00 2001 From: Argiris Kirtzidis Date: Fri, 10 Dec 2010 20:08:30 +0000 Subject: [PATCH] Introduce ObjCMessageExpr::getReceiverRange() to get the source range of the receiver. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@121517 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/AST/ExprObjC.h | 3 +++ lib/AST/Expr.cpp | 18 +++++++++++++++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/include/clang/AST/ExprObjC.h b/include/clang/AST/ExprObjC.h index aaad04b30..263ba17a0 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 93ebb7044..bb9193466 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::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(SelectorOrMethod) -- 2.11.4.GIT