[PATCH] D59620: [llvm-pdbutil] Add -type-ref-stats to help find unused type info

Reid Kleckner via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 21 10:30:01 PDT 2019


rnk added a comment.

In D59620#1438190 <https://reviews.llvm.org/D59620#1438190>, @zturner wrote:

> I don't think you can have a cycle to an unnamed type though because it's impossible to reference it.


In C, yes, so far as I can tell it's impossible to reference an unnamed struct or union from inside it.

> Or maybe you can, by doing something like:
> 
>   struct {
>     auto foo() { return this; }
>     
>     decltype(foo()) node;
>   };
> 
> 
> I'd be curious to see how well the debugger handles that.

The decltype bit isn't necessary, just having a method is enough to make a cycle between the method type and the class. So, since pretty much all types in C++ have methods, MSVC gives all C++ types "unique" names. Of course, if they are at global scope, they may not in fact be unique across the whole program, but that just means there might type confusion later on during a debugging session.

For this example, MSVC creates a fwd decl with the unique name `.?AU<unnamed-type-node>@@`:

  struct {
    auto foo() { return this; }
    int x;
  } node;
  int bar() { return node.foo()->x; }


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D59620





More information about the llvm-commits mailing list