[cfe-commits] r121517 - in /cfe/trunk: include/clang/AST/ExprObjC.h lib/AST/Expr.cpp

Argyrios Kyrtzidis akyrtzi at gmail.com
Fri Dec 10 12:08:31 PST 2010


Author: akirtzidis
Date: Fri Dec 10 14:08:30 2010
New Revision: 121517

URL: http://llvm.org/viewvc/llvm-project?rev=121517&view=rev
Log:
Introduce ObjCMessageExpr::getReceiverRange() to get the source range of the receiver.

Modified:
    cfe/trunk/include/clang/AST/ExprObjC.h
    cfe/trunk/lib/AST/Expr.cpp

Modified: cfe/trunk/include/clang/AST/ExprObjC.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ExprObjC.h?rev=121517&r1=121516&r2=121517&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/ExprObjC.h (original)
+++ cfe/trunk/include/clang/AST/ExprObjC.h Fri Dec 10 14:08:30 2010
@@ -610,6 +610,9 @@
   /// 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 {

Modified: cfe/trunk/lib/AST/Expr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Expr.cpp?rev=121517&r1=121516&r2=121517&view=diff
==============================================================================
--- cfe/trunk/lib/AST/Expr.cpp (original)
+++ cfe/trunk/lib/AST/Expr.cpp Fri Dec 10 14:08:30 2010
@@ -2330,7 +2330,23 @@
   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)





More information about the cfe-commits mailing list