Use the same logic as in TypePrinter::printTag to determine that the tag is anonymous and the separate check for namespaces.
Details
Diff Detail
- Repository
- rL LLVM
Event Timeline
test/Index/print-type.cpp | ||
---|---|---|
202 ↗ | (On Diff #175653) | Hard coded paths will probably only work on your machine ;) |
This seems to have changed the behaviour w.r.t inline struct or union decls in fields and global variables e.g.
struct foo { struct { int x; } bar; };
For the StructDecl cursor of 'bar' isAnonymous now returns true, instead of false.
I guess this was intended? But we were relying on this behaviour to collect all nested elements that were accessible through the parent struct, e.g.
struct foo { struct { int x; } bar; union { int y; int z; }; };
'y' and 'z' are accessible directly through foo by doing foo.y and foo.z., but 'x' is not, we have to do foo.bar.x. Since isAnonymous now returns true for both 'bar' and the 'inlined' anonymous union, there is no easy way to differentiate between whether it appears as part of a FieldDecl or not. The only alternative I've found is to look up the semantic parent, create a set of all the FieldDecl cursors, and then filter by the field's type's declaration cursors, which is kind of 'meh' for usability/performance, and doesn't work for all cases either.
Any alternative to get the old behaviour?