<div dir="ltr">Hi, since your patch is just a rebasing of something that was already reviewed, I think you can go ahead and commit..<div>any objection?</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Jan 27, 2015 at 7:36 PM, Loïc Jaquemet <span dir="ltr"><<a href="mailto:loic.jaquemet@gmail.com" target="_blank">loic.jaquemet@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
<br>
would it be possible to get a review for this patch (libclang/python bindings) ?<br>
<br>
Thanks<br>
<br>
2015-01-21 19:00 GMT-07:00 Loïc Jaquemet <<a href="mailto:loic.jaquemet@gmail.com">loic.jaquemet@gmail.com</a>>:<br>
<div class="HOEnZb"><div class="h5">> Please find this patches updated for .226743.<br>
><br>
><br>
> * libclang: Add three functions useful for dealing with anonymous fields.<br>
> +clang_Cursor_getOffsetOfField<br>
> +clang_Cursor_isAnonymous<br>
> +clang_Type_visitFields<br>
> Fixed: reuse CXVisitorResult instead of introducing a new enum<br>
><br>
> * Python; Add corresponding methods for dealing with anonymous fields.<br>
><br>
> * TU in print-type<br>
> adds [nbFields] in c-index-test for records<br>
> for anonymous record, shows offset of field in anonymous and parent<br>
> record. ( clang_Type_getOffsetOf/clang_Cursor_getOffsetOfField)<br>
><br>
> LLVM tests passes<br>
> python tests passees<br>
><br>
><br>
> * Reference from 2013/2014<br>
> <a href="http://lists.cs.uiuc.edu/pipermail/cfe-commits/Week-of-Mon-20140217/099453.html" target="_blank">http://lists.cs.uiuc.edu/pipermail/cfe-commits/Week-of-Mon-20140217/099453.html</a><br>
><br>
> 2015-01-21 12:28 GMT-07:00 Francois Pichet <<a href="mailto:pichet2000@gmail.com">pichet2000@gmail.com</a>>:<br>
>> Hi Loic,<br>
>><br>
>> Seems like this was never committed in trunk? Any reason why?<br>
>> I have a project with a lot of anonymous struct and this patch would be<br>
>> useful.<br>
>><br>
>> On Thu, Feb 20, 2014 at 2:40 AM, Argyrios Kyrtzidis <<a href="mailto:kyrtzidis@apple.com">kyrtzidis@apple.com</a>><br>
>> wrote:<br>
>>><br>
>>><br>
>>> On Feb 16, 2014, at 11:49 AM, Loïc Jaquemet <<a href="mailto:loic.jaquemet@gmail.com">loic.jaquemet@gmail.com</a>><br>
>>> wrote:<br>
>>><br>
>>> >><br>
>>> >> +/**<br>
>>> >> + * \brief Visitor invoked for each field found by a traversal.<br>
>>> >> + *<br>
>>> >> + * This visitor function will be invoked for each field found by<br>
>>> >> + * clang_visitCursorFields(). Its first argument is the cursor being<br>
>>> >> + * visited, its second argument is the client data provided to<br>
>>> >> + * clang_visitCursorFields().<br>
>>> >> + *<br>
>>> >> + * The visitor should return one of the \c CXFieldVisitResult values<br>
>>> >> + * to direct clang_visitCursorFields().<br>
>>> >> + */<br>
>>> >> +typedef enum CXFieldVisitResult (*CXFieldVisitor)(CXCursor C,<br>
>>> >> + CXClientData<br>
>>> >> client_data);<br>
>>> >><br>
>>> >> +CINDEX_LINKAGE unsigned clang_Type_visitFields(CXType T,<br>
>>> >> + CXFieldVisitor visitor,<br>
>>> >> + CXClientData<br>
>>> >> client_data);<br>
>>> >><br>
>>> >> In general, the visitor is not recursing, right ? In that case why not<br>
>>> >> use a simpler "getNumFields / getField" pair of functions ?<br>
>>> ><br>
>>> > Well, the source code (AST.Decl.h ) exposes a iterator on its fields.<br>
>>> > Given that in other similar cases a visitor is used, I did the same.<br>
>>> ><br>
>>> > I did not want to introduce new code/new logic.<br>
>>> > I just want to expose the iterator.<br>
>>> ><br>
>>> > Do you want me to change it to a "getNumFields / getField" pair of<br>
>>> > functions ?<br>
>>><br>
>>> I see, the visitor interface is fine.<br>
>>><br>
>>> ><br>
>>> ><br>
>>> >> +enum CXFieldVisitResult {<br>
>>> >><br>
>>> >> Could you reuse CXVisitorResult instead of introducing a new enum ?<br>
>>> ><br>
>>> > Yes. I did not see that one.<br>
>>> > Will change that.<br>
>>><br>
>>> After that, LGTM!<br>
>>><br>
>>> ><br>
>>> ><br>
>>> >><br>
>>> >><br>
>>> >> On Feb 10, 2014, at 5:13 PM, Loïc Jaquemet <<a href="mailto:loic.jaquemet@gmail.com">loic.jaquemet@gmail.com</a>><br>
>>> >> wrote:<br>
>>> >><br>
>>> >>> Hi,<br>
>>> >>><br>
>>> >>> I'm pinging back about this patch :<br>
>>> >>> * libclang: Add three functions useful for dealing with anonymous<br>
>>> >>> fields.<br>
>>> >>> +clang_Cursor_getOffsetOfField<br>
>>> >>> +clang_Cursor_isAnonymous<br>
>>> >>> +clang_Type_visitFields<br>
>>> >>><br>
>>> >>> Currently, there is no function in libclang to access clang logic that<br>
>>> >>> handles anonymous members in a record.<br>
>>> >>><br>
>>> >>> Given the current API , there is no direct method to :<br>
>>> >>> a) recover the offset of an anonymous field.<br>
>>> >>> - displayname == spelling == '', clang_Type_getOffset does not work<br>
>>> >>> + new clang_Cursor_getOffsetOfField will expose that information<br>
>>> >>> b) clearly identify that DECL as an anonymous record.<br>
>>> >>> + new clang_Cursor_isAnonymous will expose that information<br>
>>> >>><br>
>>> >>> When using clang_visitChildren, an anonymous member will be returned<br>
>>> >>> as a STRUCT_DECL/UNION_DECL.<br>
>>> >>> Currently the libclang user has to re-implement the logic to<br>
>>> >>> differentiate FIELD_DECL in the list of children nodes<br>
>>> >>> For example,<br>
>>> >>><br>
>>> >>> struct A {<br>
>>> >>> struct {int a;} typeanon;<br>
>>> >>> struct {<br>
>>> >>> int bariton;<br>
>>> >>> union {<br>
>>> >>> int foo;<br>
>>> >>> int foo2;<br>
>>> >>> };<br>
>>> >>> };<br>
>>> >>> int c;<br>
>>> >>> } ;<br>
>>> >>><br>
>>> >>> Some children are STRUCT_DECL, some are FIELD_DECL, some are<br>
>>> >>> attributes.<br>
>>> >>> Worse,<br>
>>> >>> children[0] == STRUCT_DECL (struct {int a;})<br>
>>> >>> children[1] == FIELD_DECL (typeanon)<br>
>>> >>> children[2] == STRUCT_DECL (anonymous structure)<br>
>>> >>> children[3] == FIELD_DECL (int c)<br>
>>> >>><br>
>>> >>> Sometime a STRUCT_DECL is a field (children[2]) sometimes it is just a<br>
>>> >>> STRUCT_DECL.<br>
>>> >>><br>
>>> >>> The new function clang_Type_visitFields will expose the existing<br>
>>> >>> libclang capabilities to list only fields, and not all children node,<br>
>>> >>> as does clang_visitChildren.<br>
>>> >>><br>
>>> >>> fields[0] == FIELD_DECL (first structure - typeanon)<br>
>>> >>> fields[1] == FIELD_DECL (second anonymous structure)<br>
>>> >>> fields[2] == FIELD_DECL (int c)<br>
>>> >>><br>
>>> >>><br>
>>> >>><br>
>>> >>><br>
>>> >>><br>
>>> >>><br>
>>> >>><br>
>>> >>> --<br>
>>> >>> Loïc Jaquemet<br>
>>> >>> <libclang-visit-fields.201116><br>
>>> >><br>
>>> ><br>
>>> ><br>
>>> ><br>
>>> > --<br>
>>> > Loïc Jaquemet<br>
>>><br>
>>><br>
>>> _______________________________________________<br>
>>> cfe-commits mailing list<br>
>>> <a href="mailto:cfe-commits@cs.uiuc.edu">cfe-commits@cs.uiuc.edu</a><br>
>>> <a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a><br>
>><br>
>><br>
><br>
><br>
><br>
> --<br>
> Loïc Jaquemet<br>
<br>
<br>
<br>
</div></div><span class="HOEnZb"><font color="#888888">--<br>
Loïc Jaquemet<br>
</font></span></blockquote></div><br></div>