<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br><div><div>On Jun 27, 2011, at 1:39 PM, Argyrios Kyrtzidis wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><div>On Jun 27, 2011, at 12:48 PM, Douglas Gregor wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div><br>On Jun 27, 2011, at 12:42 PM, Argyrios Kyrtzidis wrote:<br><br><blockquote type="cite">Author: akirtzidis<br></blockquote><blockquote type="cite">Date: Mon Jun 27 14:42:20 2011<br></blockquote><blockquote type="cite">New Revision: 133929<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">URL: <a href="http://llvm.org/viewvc/llvm-project?rev=133929&view=rev">http://llvm.org/viewvc/llvm-project?rev=133929&view=rev</a><br></blockquote><blockquote type="cite">Log:<br></blockquote><blockquote type="cite">[libclang] Avoid having the cursor of an expression "overwrite" the annotation of the<br></blockquote><blockquote type="cite">variable declaration that it belongs to.<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">This can happen for C++ constructor expressions whose range generally<br></blockquote><blockquote type="cite">include the variable declaration, e.g.:<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"> MyCXXClass foo; // Make sure we don't annotate 'foo' as a CallExpr cursor.<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"><a href="rdar://9124499.">rdar://9124499.</a><br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">Modified:<br></blockquote><blockquote type="cite">   cfe/trunk/test/Index/annotate-tokens.cpp<br></blockquote><blockquote type="cite">   cfe/trunk/tools/libclang/CIndex.cpp<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">Modified: cfe/trunk/test/Index/annotate-tokens.cpp<br></blockquote><blockquote type="cite">URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/annotate-tokens.cpp?rev=133929&r1=133928&r2=133929&view=diff">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/annotate-tokens.cpp?rev=133929&r1=133928&r2=133929&view=diff</a><br></blockquote><blockquote type="cite">==============================================================================<br></blockquote><blockquote type="cite">--- cfe/trunk/test/Index/annotate-tokens.cpp (original)<br></blockquote><blockquote type="cite">+++ cfe/trunk/test/Index/annotate-tokens.cpp Mon Jun 27 14:42:20 2011<br></blockquote><blockquote type="cite">@@ -17,9 +17,10 @@<br></blockquote><blockquote type="cite">struct S2 { S1 *operator->(); };<br></blockquote><blockquote type="cite">void test3(S2 s2) {<br></blockquote><blockquote type="cite">  s2->f();<br></blockquote><blockquote type="cite">+  X foo;<br></blockquote><blockquote type="cite">}<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">-// RUN: c-index-test -test-annotate-tokens=%s:1:1:20:1 %s | FileCheck %s<br></blockquote><blockquote type="cite">+// RUN: c-index-test -test-annotate-tokens=%s:1:1:21:1 %s | FileCheck %s<br></blockquote><blockquote type="cite">// CHECK: Keyword: "struct" [1:1 - 1:7] StructDecl=bonk:1:8 (Definition)<br></blockquote><blockquote type="cite">// CHECK: Identifier: "bonk" [1:8 - 1:12] StructDecl=bonk:1:8 (Definition)<br></blockquote><blockquote type="cite">// CHECK: Punctuation: "{" [1:13 - 1:14] StructDecl=bonk:1:8 (Definition)<br></blockquote><blockquote type="cite">@@ -115,4 +116,7 @@<br></blockquote><blockquote type="cite">// CHECK: Punctuation: "(" [19:8 - 19:9] CallExpr=f:16:18<br></blockquote><blockquote type="cite">// CHECK: Punctuation: ")" [19:9 - 19:10] CallExpr=f:16:18<br></blockquote><blockquote type="cite">// CHECK: Punctuation: ";" [19:10 - 19:11] UnexposedStmt=<br></blockquote><blockquote type="cite">-// CHECK: Punctuation: "}" [20:1 - 20:2] UnexposedStmt=<br></blockquote><blockquote type="cite">+// CHECK: Identifier: "X" [20:3 - 20:4] TypeRef=struct X:7:8<br></blockquote><blockquote type="cite">+// CHECK: Identifier: "foo" [20:5 - 20:8] VarDecl=foo:20:5 (Definition)<br></blockquote><blockquote type="cite">+// CHECK: Punctuation: ";" [20:8 - 20:9] UnexposedStmt=<br></blockquote><blockquote type="cite">+// CHECK: Punctuation: "}" [21:1 - 21:2] UnexposedStmt=<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">Modified: cfe/trunk/tools/libclang/CIndex.cpp<br></blockquote><blockquote type="cite">URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CIndex.cpp?rev=133929&r1=133928&r2=133929&view=diff">http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CIndex.cpp?rev=133929&r1=133928&r2=133929&view=diff</a><br></blockquote><blockquote type="cite">==============================================================================<br></blockquote><blockquote type="cite">--- cfe/trunk/tools/libclang/CIndex.cpp (original)<br></blockquote><blockquote type="cite">+++ cfe/trunk/tools/libclang/CIndex.cpp Mon Jun 27 14:42:20 2011<br></blockquote><blockquote type="cite">@@ -4627,6 +4627,24 @@<br></blockquote><blockquote type="cite">    break;<br></blockquote><blockquote type="cite">  }<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">+  // Avoid having the cursor of an expression "overwrite" the annotation of the<br></blockquote><blockquote type="cite">+  // variable declaration that it belongs to.<br></blockquote><blockquote type="cite">+  // This can happen for C++ constructor expressions whose range generally<br></blockquote><blockquote type="cite">+  // include the variable declaration, e.g.:<br></blockquote><blockquote type="cite">+  //  MyCXXClass foo; // Make sure we don't annotate 'foo' as a CallExpr cursor.<br></blockquote><blockquote type="cite">+  if (clang_isExpression(cursorK)) {<br></blockquote><blockquote type="cite">+    Expr *E = getCursorExpr(cursor);<br></blockquote><blockquote type="cite">+    if (Decl *D = getCursorDecl(cursor)) {<br></blockquote><br>I'm confused by this logic, since a cursor can't be both a declaration and an expression. Is the latter supposed to be<br></div></blockquote><div><br></div><div>I see </div><div><br></div><div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; "><span style="color: #056142">CXCursor</span> cxcursor::MakeCXCursor(<span style="color: #056142">Stmt</span> *S, <span style="color: #056142">Decl</span> *Parent,</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; ">                                <span style="color: #056142">CXTranslationUnit</span> TU)</div></div><div><br></div><div>making statement/expression cursors including the parent Decl. Is this not the case ?</div></div></div></blockquote></div><br><div><br></div><div>Ah, yes, this will work. We should really have a function that specifically extracts the parent declaration of a statement or expression cursor, but oh well.</div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre">    </span>- Doug</div></body></html>