View Issue Details [ Jump to Notes ] | [ Print ] | ||||||||
ID | Project | Category | View Status | Date Submitted | Last Update | ||||
0005058 | GCC-XML | public | 2007-05-18 05:59 | 2007-05-20 17:52 | |||||
Reporter | Bryan Ischo | ||||||||
Assigned To | Brad King | ||||||||
Priority | normal | Severity | feature | Reproducibility | always | ||||
Status | closed | Resolution | fixed | ||||||
Platform | OS | OS Version | |||||||
Summary | 0005058: Feature request: include friends list in output | ||||||||
Description | Currently the GCC sources that GCCXML is based on include information on the friend declarations of a struct or class. This information is not being output by GCCXML. I would find it very useful to have this friend information included in the output. In fact, it is critical for correct functioning of my project. Thank you! | ||||||||
Tags | No tags attached. | ||||||||
Attached Files | |||||||||
Relationships | |
Relationships |
Notes | |
(0007700) Brad King (manager) 2007-05-19 09:44 |
The following change adds a "befriending" attribute to class and function elements. It lists the classes that grand friendship to the current class or function. For example class A; void f(A&); class A { friend void f(A&); }; The xml Function element for function "f" will contain a befriending attribute that lists the id of the Class element for class "A". The other direction is not as readily available in the GCC internal representation...that is to list "f" as a friend of "A" in the Class element for "A". However this information can be reconstructed from the new xml output pretty easily. /cvsroot/GCC_XML/gccxml/GCC/gcc/cp/../../../GCC_XML/xml.c,v <-- xml.c new revision: 1.115; previous revision: 1.114 |
(0007701) Bryan Ischo (reporter) 2007-05-20 03:17 |
Thank you very much for your fast response to this feature request! I don't understand the GCC code very well but the cp-tree.h data structure lang_class_type has a friend_classes tree as well as a befriending_classes tree. Would the former work for finding the friend classes? Probably I'm not looking at the right structure though, because if it was that easy I am sure you would have done it! I can still work with befriending classes, but it will be a little less convenient. If it's not possible to easily get "friends" then that's fine, I can work with befriending, and I very much appreciate your efforts on this feature request! |
(0007702) Brad King (manager) 2007-05-20 09:47 |
The GCC internal representation always has to be accessed through all those macros defined in cp-tree.h and cannot safely be accessed by directly looking at the struct definitions. I think they change the definitions over time and use the macros to maintain a consistent interface. Anyway, there is a macro to get at friend_classes called CLASSTYPE_FRIEND_CLASSES. The problem is that it lists only the other classes that are friends and not the functions. Including this in the output as a list of friends would create the same problem there is with the members list. The "members" attribute lists some of the members but not all. All members of a class have a "context" attribute that refers to the class, but not all of them will be listed in the "members" attribute. This has led to confusion for users in the past and I've actually stopped using the members attribute at all in my code that uses the output. It's there only for backwards compatibility. I don't want to create an equally confusing problem with the friends...especially because I'm not confident that even all class friends are in that friend_classes list. Things get pretty tricky when there are friend templates, and GCC does not keep track of everything in one place. Ideally gccxml itself should use the context and befriending attributes themselves to reconstruct the members and friends lists automatically. I've avoided doing this because it would require a two-pass dump and alot of extra data structures which are more easily implemented in a client. |
(0007703) Bryan Ischo (reporter) 2007-05-20 17:52 |
Thank you for the explanation, and thanks again for your very fast fix to address my feature request! |
Notes |
Issue History | |||
Date Modified | Username | Field | Change |
Issue History |
Copyright © 2000 - 2018 MantisBT Team |