When emitting CodeView debug information, C++ lambda types need a unique identifier so Visual Studio can match the forward reference for the type to the definition. Currently they are all named "<unnamed-tag>". This patch, also necessary for D32498, will enable debugging of captured variables within lambdas using Visual Studio.
Previous LF_CLASS type record for a lambda looks like this:
Class (0x100A) { TypeLeafKind: LF_CLASS (0x1504) ... Name: main::<unnamed-tag> }
After this change the type record looks like this:
Class (0x100A) { TypeLeafKind: LF_CLASS (0x1504) ... Name: main::<unnamed-tag> LinkageName: .?AV<lambda_0>@?0??main@@9@ }
Manufacturing a better "name" for the lambda object is not necessary to allow proper debugging of captured variables.
These comments and method names don't make sense anymore, though. We can't actually produce unique names for internal types, it's impossible without some kind of per-TU GUID.
I think this code would be a lot less confusing if we rename this to something more mechanical like getTypeIdentifier. CodeView needs identifiers for all C++ types, even if the names aren't unique and might collide across TUs. For DWARF, we only use identifiers if we have a unique C++ mangled name. The comment should say something about that.
Does that make sense?