[PATCH] D54996: [libclang] Fix clang_Cursor_isAnonymous

Jorn Vernee via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Apr 27 06:38:28 PDT 2019


JornVernee added a comment.
Herald added a project: LLVM.

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 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).

Any alternative to get the old behaviour?


Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D54996/new/

https://reviews.llvm.org/D54996





More information about the llvm-commits mailing list