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