From: Argyrios Kyrtzidis Date: Fri, 10 Dec 2010 20:08:30 +0000 (+0000) Subject: Introduce ObjCMessageExpr::getReceiverRange() to get the source range of the receiver. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e005d19456e6fb73ace33f25e02ac10e22dd063f;p=clang 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 --- 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::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)