[PATCH] D39622: Fix type name generation in DWARF for template instantiations with enum types and template specializations
Paul Robinson via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Dec 13 15:07:24 PST 2017
probinson added a comment.
Philosophically, mangled names and DWARF information serve different purposes, and I don't think you will find one true solution where both of them can yield the same name that everyone will be happy with. Mangled names exist to provide unique and reproducible identifiers for the "same" entity across compilation units. They are carefully specified (for example) to allow a linker to associate a reference in one object file to a definition in a different object file, and be guaranteed that the association is correct. A demangled name is a necessarily context-free translation of the mangled name into something that has a closer relationship to how a human would think of or write the name of the thing, but isn't necessarily the only way to write the name of the thing.
DWARF names are (deliberately not carefully specified) strings that ought to bear some relationship to how source code would name the thing, but you probably don't want to attach semantic significance to those names. This is rather emphatically true for names containing template parameters. Typedefs (and their recent offspring, 'using' aliases) are your sworn enemy here. Enums, as you have found, are also a problem.
Basically, the type of an entity does not have a unique name, and trying to coerce different representations of the type into having the same unique name is a losing battle.
More information about the cfe-commits