<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"><base href="x-msg://1219/"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><div>On Feb 9, 2013, at 7:58 AM, Victor Gaydov <<a href="mailto:victor@enise.org">victor@enise.org</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div style="font-size: 9pt; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-family: monospace; "><div style="white-space: pre-wrap; margin: 0px; text-indent: 0px; ">Victor Gaydov (Sunday 03 February 2013 00:49:16):</div><div style="white-space: pre-wrap; margin: 0px; text-indent: 0px; ">> Hello!</div><div style="white-space: pre-wrap; margin: 0px; text-indent: 0px; ">> </div><div style="white-space: pre-wrap; margin: 0px; text-indent: 0px; ">> 1) When traversing AST (with clang_visitChildren) parsed from this code:</div><div style="white-space: pre-wrap; margin: 0px; text-indent: 0px; ">> > namespace foo {</div><div style="white-space: pre-wrap; margin: 0px; text-indent: 0px; ">> >   struct bar {};</div><div style="white-space: pre-wrap; margin: 0px; text-indent: 0px; ">> >   struct baz {</div><div style="white-space: pre-wrap; margin: 0px; text-indent: 0px; ">> >     bar qux();</div><div style="white-space: pre-wrap; margin: 0px; text-indent: 0px; ">> >   };</div><div style="white-space: pre-wrap; margin: 0px; text-indent: 0px; ">> > }</div><div style="white-space: pre-wrap; margin: 0px; text-indent: 0px; ">> > </div><div style="white-space: pre-wrap; margin: 0px; text-indent: 0px; ">> > foo::bar foo::baz::qux() {}</div><div style="white-space: pre-wrap; margin: 0px; text-indent: 0px; ">> </div><div style="white-space: pre-wrap; margin: 0px; text-indent: 0px; ">> ..following nodes are visited for qux() definition (last line):</div><div style="white-space: pre-wrap; margin: 0px; text-indent: 0px; ">></div><div style="white-space: pre-wrap; margin: 0px; text-indent: 0px; ">> > +--------------+---------+--------+-----------------+</div><div style="white-space: pre-wrap; margin: 0px; text-indent: 0px; ">> > | kind         | parent  | text   | spelling        |</div><div style="white-space: pre-wrap; margin: 0px; text-indent: 0px; ">> > +--------------+---------+--------+-----------------+</div><div style="white-space: pre-wrap; margin: 0px; text-indent: 0px; ">> > | NamespaceRef | qux()   | foo    | foo             |</div><div style="white-space: pre-wrap; margin: 0px; text-indent: 0px; ">> > | TypeRef      | qux()   | bar    | struct foo::bar |</div><div style="white-space: pre-wrap; margin: 0px; text-indent: 0px; ">> > | NamespaceRef | qux()   | foo    | foo             |</div><div style="white-space: pre-wrap; margin: 0px; text-indent: 0px; ">> > | TypeRef      | qux()   | baz    | struct foo::baz |</div><div style="white-space: pre-wrap; margin: 0px; text-indent: 0px; ">> > +--------------+---------+--------+-----------------+</div><div style="white-space: pre-wrap; margin: 0px; text-indent: 0px; ">> </div><div style="white-space: pre-wrap; margin: 0px; text-indent: 0px; ">> First two nodes are function return type and second two nodes are function</div><div style="white-space: pre-wrap; margin: 0px; text-indent: 0px; ">> namespace qualifiers.</div><div style="white-space: pre-wrap; margin: 0px; text-indent: 0px; ">> </div><div style="white-space: pre-wrap; margin: 0px; text-indent: 0px; ">> Is it possible to determine, if visited node (cursor) belongs to return</div><div style="white-space: pre-wrap; margin: 0px; text-indent: 0px; ">> type or to qualifier?</div><div style="white-space: pre-wrap; margin: 0px; text-indent: 0px; ">> </div><div style="white-space: pre-wrap; margin: 0px; text-indent: 0px; ">> [...]</div><p style="white-space: pre-wrap; margin: 0px; text-indent: 0px; "> </p><div style="white-space: pre-wrap; margin: 0px; text-indent: 0px; ">Update: I also was unable to get namespace qualifiers of FunctionDecl with clang_getCursorReferenceNameRange() and didn't find anything helpful in clang/tools/c-index-test.c.</div><p style="white-space: pre-wrap; margin: 0px; text-indent: 0px; "> </p><div style="white-space: pre-wrap; margin: 0px; text-indent: 0px; ">So is it impossible to get qualified name of function and its return type (when both are qualified) with current API?</div><p style="white-space: pre-wrap; margin: 0px; text-indent: 0px; "> </p><div style="white-space: pre-wrap; margin: 0px; text-indent: 0px; ">If this is so, I would like to write a patch. One possible approach is to transform AST for this code:</div><p style="white-space: pre-wrap; margin: 0px; text-indent: 0px; "> </p><div style="white-space: pre-wrap; margin: 0px; text-indent: 0px; ">> foo::bar foo::baz::qux() {}</div><p style="white-space: pre-wrap; margin: 0px; text-indent: 0px; "> </p><div style="white-space: pre-wrap; margin: 0px; text-indent: 0px; ">from:</div><p style="white-space: pre-wrap; margin: 0px; text-indent: 0px; "> </p><div style="white-space: pre-wrap; margin: 0px; text-indent: 0px; ">>       qux <-- FunctionDecl</div><div style="white-space: pre-wrap; margin: 0px; text-indent: 0px; ">>       / \</div><div style="white-space: pre-wrap; margin: 0px; text-indent: 0px; ">>      /   \</div><div style="white-space: pre-wrap; margin: 0px; text-indent: 0px; ">>     /|   |\</div><div style="white-space: pre-wrap; margin: 0px; text-indent: 0px; ">>    / |   | \</div><div style="white-space: pre-wrap; margin: 0px; text-indent: 0px; ">>   /  |   |  \</div><div style="white-space: pre-wrap; margin: 0px; text-indent: 0px; ">>  /   |   |   \</div><div style="white-space: pre-wrap; margin: 0px; text-indent: 0px; ">> foo bar foo baz</div><p style="white-space: pre-wrap; margin: 0px; text-indent: 0px; "> </p><div style="white-space: pre-wrap; margin: 0px; text-indent: 0px; ">to:</div><p style="white-space: pre-wrap; margin: 0px; text-indent: 0px; "> </p><div style="white-space: pre-wrap; margin: 0px; text-indent: 0px; ">>         qux <-- FunctionDecl</div><div style="white-space: pre-wrap; margin: 0px; text-indent: 0px; ">>         / \</div><div style="white-space: pre-wrap; margin: 0px; text-indent: 0px; ">>        /   \</div><div style="white-space: pre-wrap; margin: 0px; text-indent: 0px; ">>       / \   \</div><div style="white-space: pre-wrap; margin: 0px; text-indent: 0px; ">>      /  foo baz</div><div style="white-space: pre-wrap; margin: 0px; text-indent: 0px; ">>     /</div><div style="white-space: pre-wrap; margin: 0px; text-indent: 0px; ">>    o <-- FunctionReturnType (new cursor type)</div><div style="white-space: pre-wrap; margin: 0px; text-indent: 0px; ">>   / \</div><div style="white-space: pre-wrap; margin: 0px; text-indent: 0px; ">>  /   \</div><div style="white-space: pre-wrap; margin: 0px; text-indent: 0px; ">> foo  bar</div><p style="white-space: pre-wrap; margin: 0px; text-indent: 0px; "> </p><div style="white-space: pre-wrap; margin: 0px; text-indent: 0px; ">But I guess this can break backward compatibility? I'm new to libclang, so I need some advice about preferred way to implement such patch.</div></div></blockquote><div><br></div><div>I suggest enhancing "clang_Cursor_getSpellingNameRange()" to work similar as "clang_getCursorReferenceNameRange()" and have it accept the same options (e.g. CXNameRange_WantQualifier).</div><div>Then you can pass it the cursor for the function and compare the CXSourceRanges that it gives you with the ones for the NamespaceRef/TypeRef cursors.</div><br><blockquote type="cite"><div style="font-size: 9pt; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-family: monospace; "><p style="white-space: pre-wrap; margin: 0px; text-indent: 0px; "> </p><div style="white-space: pre-wrap; margin: 0px; text-indent: 0px; ">Thanks, sorry for self-replying.</div><p style="white-space: pre-wrap; margin: 0px; text-indent: 0px; "> </p><div style="white-space: pre-wrap; margin: 0px; text-indent: 0px; ">-- Victor</div><p style="white-space: pre-wrap; margin: 0px; text-indent: 0px; "> </p>_______________________________________________<br>cfe-dev mailing list<br><a href="mailto:cfe-dev@cs.uiuc.edu">cfe-dev@cs.uiuc.edu</a><br><a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev</a></div></blockquote></div><br></body></html>