[cfe-dev] Get name from RecordDecl

Mikhail Ramalho via cfe-dev cfe-dev at lists.llvm.org
Mon May 9 06:35:04 PDT 2016


I thought so too but from the documentation:

  /// isAnonymousStructOrUnion - Whether this is an anonymous struct
  /// or union. To be an anonymous struct or union, it must have been
  /// declared without a name and there must be no objects of this
  /// type declared, e.g.,
  /// @code
  ///   union { int i; float f; };
  /// @endcode
  /// is an anonymous union but neither of the following are:
  /// @code
  ///  union X { int i; float f; };
  ///  *union { int i; float f; } obj*;
  /// @endcode

So I thought that it would create a tag name using the field name, which
doesn't seem to be the case.

Anyway, I decided to follow the cope from TypePrinter
<http://clang.llvm.org/doxygen/TypePrinter_8cpp_source.html#l00906> and
ignore a struct without name when generating the scope.

Thank you,


2016-05-09 8:34 GMT+01:00 Miklos Vajna via cfe-dev <cfe-dev at lists.llvm.org>:

> Hi,
>
> On Fri, May 06, 2016 at 01:02:43PM +0100, Mikhail Ramalho via cfe-dev <
> cfe-dev at lists.llvm.org> wrote:
> > typedef struct
> > {
> >   int __count;
> >
> > *  union*
> > *  {*
> > *    int __wch;*
> > *    char __wchb[4];*
> > *  } __value;*
> >
> > } __mbstate_t;
>
> ...
>
> > The problem is the inner union, which is not anonymous but I can't get
> the
> > name. The bold assertion always fails.
>
> Have a look at the AST with 'clang++ -Xclang -ast-dump -fsyntax-only',
> IIUC the union is anonymous, __value is the name of the member, not of
> the union.
>
> Regards,
>
> Miklos
>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
>
>


-- 

Mikhail Ramalho.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20160509/13b2b65c/attachment.html>


More information about the cfe-dev mailing list