<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">On Apr 23, 2013, at 12:03 PM, Jordan Rose <<a href="mailto:jordan_rose@apple.com">jordan_rose@apple.com</a>> wrote:<br><div><br class="Apple-interchange-newline"><blockquote type="cite"><div style="letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;">Sorry, why is this right way to implement this? 'self' is very deliberately not a special kind of expression in Objective-C. Why not expose this on the associated ParmVarDecl instead?<br></div></blockquote><div><br></div><div>What is the advantage with that approach ? Whether there is a ParmVarDecl or not seems like an implementation detail of the AST. If you are worried that there is one more cursor to consider, I'd argue the same applies for CXCursor_CXXThisExpr.</div><br><blockquote type="cite"><div style="letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><br>Jordan<br><br><br>On Apr 23, 2013, at 10:57 , Argyrios Kyrtzidis <<a href="mailto:akyrtzi@gmail.com">akyrtzi@gmail.com</a>> wrote:<br><br><blockquote type="cite">Author: akirtzidis<br>Date: Tue Apr 23 12:57:17 2013<br>New Revision: 180127<br><br>URL: <a href="http://llvm.org/viewvc/llvm-project?rev=180127&view=rev">http://llvm.org/viewvc/llvm-project?rev=180127&view=rev</a><br>Log:<br>[libclang] Introduce a CXCursor_ObjCSelfExpr cursor, which is the equivalent of CXCursor_CXXThisExpr for C++ code.<br><br><a href="rdar://13717006">rdar://13717006</a><br><br>Modified:<br>  cfe/trunk/include/clang-c/Index.h<br>  cfe/trunk/test/Index/annotate-tokens.m<br>  cfe/trunk/tools/libclang/CIndex.cpp<br>  cfe/trunk/tools/libclang/CXCursor.cpp<br><br>Modified: cfe/trunk/include/clang-c/Index.h<br>URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang-c/Index.h?rev=180127&r1=180126&r2=180127&view=diff<br>==============================================================================<br>--- cfe/trunk/include/clang-c/Index.h (original)<br>+++ cfe/trunk/include/clang-c/Index.h Tue Apr 23 12:57:17 2013<br>@@ -32,7 +32,7 @@<br>* compatible, thus CINDEX_VERSION_MAJOR is expected to remain stable.<br>*/<br>#define CINDEX_VERSION_MAJOR 0<br>-#define CINDEX_VERSION_MINOR 18<br>+#define CINDEX_VERSION_MINOR 19<br><br>#define CINDEX_VERSION_ENCODE(major, minor) ( \<br>     ((major) * 10000)                       \<br>@@ -1903,7 +1903,11 @@ enum CXCursorKind {<br>  */<br> CXCursor_ObjCBoolLiteralExpr           = 145,<br><br>-  CXCursor_LastExpr                      = CXCursor_ObjCBoolLiteralExpr,<br>+  /** \brief Represents the "self" expression in a ObjC method.<br>+   */<br>+  CXCursor_ObjCSelfExpr                  = 146,<br>+<br>+  CXCursor_LastExpr                      = CXCursor_ObjCSelfExpr,<br><br> /* Statements */<br> CXCursor_FirstStmt                     = 200,<br><br>Modified: cfe/trunk/test/Index/annotate-tokens.m<br>URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/annotate-tokens.m?rev=180127&r1=180126&r2=180127&view=diff<br>==============================================================================<br>--- cfe/trunk/test/Index/annotate-tokens.m (original)<br>+++ cfe/trunk/test/Index/annotate-tokens.m Tue Apr 23 12:57:17 2013<br>@@ -281,7 +281,7 @@ static Rdar8595462_A * Rdar8595462_stati<br>// CHECK: Punctuation: ")" [40:19 - 40:20] CallExpr=ibaction_test:36:12<br>// CHECK: Punctuation: ";" [40:20 - 40:21] CompoundStmt=<br>// CHECK: Punctuation: "[" [41:5 - 41:6] ObjCMessageExpr=foo::34:9<br>-// CHECK: Identifier: "self" [41:6 - 41:10] DeclRefExpr=self:0:0<br>+// CHECK: Identifier: "self" [41:6 - 41:10] ObjCSelfExpr=self:0:0<br>// CHECK: Identifier: "foo" [41:11 - 41:14] ObjCMessageExpr=foo::34:9<br>// CHECK: Punctuation: ":" [41:14 - 41:15] ObjCMessageExpr=foo::34:9<br>// CHECK: Literal: "0" [41:15 - 41:16] IntegerLiteral=<br>@@ -391,7 +391,7 @@ static Rdar8595462_A * Rdar8595462_stati<br>// CHECK: Identifier: "local" [76:9 - 76:14] VarDecl=local:76:9 (Definition)<br>// CHECK: Punctuation: "=" [76:15 - 76:16] VarDecl=local:76:9 (Definition)<br>// CHECK: Punctuation: "[" [76:17 - 76:18] ObjCMessageExpr=foo::66:9<br>-// CHECK: Identifier: "self" [76:18 - 76:22] DeclRefExpr=self:0:0<br>+// CHECK: Identifier: "self" [76:18 - 76:22] ObjCSelfExpr=self:0:0<br>// CHECK: Identifier: "foo" [76:23 - 76:26] ObjCMessageExpr=foo::66:9<br>// CHECK: Punctuation: ":" [76:26 - 76:27] ObjCMessageExpr=foo::66:9<br>// CHECK: Identifier: "VAL" [76:27 - 76:30] macro expansion=VAL:63:9<br>@@ -401,7 +401,7 @@ static Rdar8595462_A * Rdar8595462_stati<br>// CHECK: Identifier: "second" [77:9 - 77:15] VarDecl=second:77:9 (Definition)<br>// CHECK: Punctuation: "=" [77:16 - 77:17] VarDecl=second:77:9 (Definition)<br>// CHECK: Punctuation: "[" [77:18 - 77:19] ObjCMessageExpr=foo::66:9<br>-// CHECK: Identifier: "self" [77:19 - 77:23] DeclRefExpr=self:0:0<br>+// CHECK: Identifier: "self" [77:19 - 77:23] ObjCSelfExpr=self:0:0<br>// CHECK: Identifier: "foo" [77:24 - 77:27] ObjCMessageExpr=foo::66:9<br>// CHECK: Punctuation: ":" [77:27 - 77:28] ObjCMessageExpr=foo::66:9<br>// CHECK: Literal: "0" [77:28 - 77:29] IntegerLiteral=<br>@@ -518,7 +518,7 @@ static Rdar8595462_A * Rdar8595462_stati<br>// CHECK-INSIDE_BLOCK: Identifier: "result" [127:9 - 127:15] VarDecl=result:127:9 (Definition)<br>// CHECK-INSIDE_BLOCK: Punctuation: "=" [127:16 - 127:17] VarDecl=result:127:9 (Definition)<br>// CHECK-INSIDE_BLOCK: Punctuation: "[" [127:18 - 127:19] ObjCMessageExpr=blah::124:8<br>-// CHECK-INSIDE_BLOCK: Identifier: "self" [127:19 - 127:23] DeclRefExpr=self:0:0<br>+// CHECK-INSIDE_BLOCK: Identifier: "self" [127:19 - 127:23] ObjCSelfExpr=self:0:0<br>// CHECK-INSIDE_BLOCK: Identifier: "blah" [127:24 - 127:28] ObjCMessageExpr=blah::124:8<br>// CHECK-INSIDE_BLOCK: Punctuation: ":" [127:28 - 127:29] ObjCMessageExpr=blah::124:8<br>// CHECK-INSIDE_BLOCK: Literal: "5" [127:29 - 127:30] IntegerLiteral=<br>@@ -530,7 +530,7 @@ static Rdar8595462_A * Rdar8595462_stati<br>// CHECK-INSIDE_BLOCK: Punctuation: "*" [128:17 - 128:18] VarDecl=a:128:18 (Definition)<br>// CHECK-INSIDE_BLOCK: Identifier: "a" [128:18 - 128:19] VarDecl=a:128:18 (Definition)<br>// CHECK-INSIDE_BLOCK: Punctuation: "=" [128:20 - 128:21] VarDecl=a:128:18 (Definition)<br>-// CHECK-INSIDE_BLOCK: Identifier: "self" [128:22 - 128:26] DeclRefExpr=self:0:0<br>+// CHECK-INSIDE_BLOCK: Identifier: "self" [128:22 - 128:26] ObjCSelfExpr=self:0:0<br><br>// RUN: c-index-test -test-annotate-tokens=%s:134:1:138:1 %s -DIBOutlet='__attribute__((iboutlet))' -DIBAction='void)__attribute__((ibaction)' | FileCheck -check-prefix=CHECK-PROP-AFTER-METHOD %s<br>// CHECK-PROP-AFTER-METHOD: Punctuation: "@" [134:1 - 134:2] ObjCInterfaceDecl=Rdar8062781:134:12<br><br>Modified: cfe/trunk/tools/libclang/CIndex.cpp<br>URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CIndex.cpp?rev=180127&r1=180126&r2=180127&view=diff<br>==============================================================================<br>--- cfe/trunk/tools/libclang/CIndex.cpp (original)<br>+++ cfe/trunk/tools/libclang/CIndex.cpp Tue Apr 23 12:57:17 2013<br>@@ -3588,6 +3588,8 @@ CXString clang_getCursorKindSpelling(enu<br>     return cxstring::createRef("ObjCStringLiteral");<br> case CXCursor_ObjCBoolLiteralExpr:<br>     return cxstring::createRef("ObjCBoolLiteralExpr");<br>+  case CXCursor_ObjCSelfExpr:<br>+      return cxstring::createRef("ObjCSelfExpr");<br> case CXCursor_ObjCEncodeExpr:<br>     return cxstring::createRef("ObjCEncodeExpr");<br> case CXCursor_ObjCSelectorExpr:<br><br>Modified: cfe/trunk/tools/libclang/CXCursor.cpp<br>URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CXCursor.cpp?rev=180127&r1=180126&r2=180127&view=diff<br>==============================================================================<br>--- cfe/trunk/tools/libclang/CXCursor.cpp (original)<br>+++ cfe/trunk/tools/libclang/CXCursor.cpp Tue Apr 23 12:57:17 2013<br>@@ -435,7 +435,21 @@ CXCursor cxcursor::MakeCXCursor(const St<br>   K = CXCursor_SizeOfPackExpr;<br>   break;<br><br>-  case Stmt::DeclRefExprClass:           <br>+  case Stmt::DeclRefExprClass:<br>+    if (const ImplicitParamDecl *IPD =<br>+         dyn_cast_or_null<ImplicitParamDecl>(cast<DeclRefExpr>(S)->getDecl())) {<br>+      if (const ObjCMethodDecl *MD =<br>+            dyn_cast<ObjCMethodDecl>(IPD->getDeclContext())) {<br>+        if (MD->getSelfDecl() == IPD) {<br>+          K = CXCursor_ObjCSelfExpr;<br>+          break;<br>+        }<br>+      }<br>+    }<br>+<br>+    K = CXCursor_DeclRefExpr;<br>+    break;<br>+<br> case Stmt::DependentScopeDeclRefExprClass:<br> case Stmt::SubstNonTypeTemplateParmExprClass:<br> case Stmt::SubstNonTypeTemplateParmPackExprClass:<br><br><br>_______________________________________________<br>cfe-commits mailing list<br>cfe-commits@cs.uiuc.edu<br>http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</blockquote></div></blockquote></div><br></body></html>