[llvm-bugs] [Bug 39607] New: clang-cl doesn't emit LF_NESTTYPE records for nested template instantiations
via llvm-bugs
llvm-bugs at lists.llvm.org
Fri Nov 9 13:19:39 PST 2018
https://bugs.llvm.org/show_bug.cgi?id=39607
Bug ID: 39607
Summary: clang-cl doesn't emit LF_NESTTYPE records for nested
template instantiations
Product: libraries
Version: trunk
Hardware: PC
OS: Windows NT
Status: NEW
Severity: enhancement
Priority: P
Component: DebugInfo
Assignee: rnk at google.com
Reporter: zturner at google.com
CC: aleksandr.urakov at jetbrains.com,
jdevlieghere at apple.com, llvm-bugs at lists.llvm.org,
mosescu at google.com
struct U {
template<typename Param>
struct V { };
};
template<typename T>
void foo() {
T t;
}
int main(int argc, char **argv) {
foo<U>();
foo<U::V<int>>();
return 0;
}
MSVC will output this in the field list for U.
0x1004 | LF_STRUCTURE [size = 48] `U::V<int>`
unique name: `.?AU?$V at H@U@@`
vtable: <no type>, base list: <no type>, field list: <no type>
options: forward ref (-> 0x1008) | has unique name | is nested,
sizeof 0
0x1005 | LF_FIELDLIST [size = 20]
- LF_NESTTYPE [name = `?$V at H`, parent = 0x1004]
0x1006 | LF_STRUCTURE [size = 32] `U`
unique name: `.?AUU@@`
vtable: <no type>, base list: <no type>, field list: 0x1005
options: contains nested class | has unique name, sizeof 1
We do not output this LF_NESTTYPE at all. This is useful when parsing debug
info in order to be able to reconstruct the DeclContext hierarchy to build an
AST from the debug info. Without this, we won't be able to figure out what
DeclContext to put these nested template instantiations into.
With it, the algorithm is:
1) We found an LF_STRUCTURE with the contains nested class flag set.
2) We walk it's field list, find the LF_NESTTYPE.
3) It points to 0x1004, so we load the unique name for record 0x1004, call this
`actual`
4) Make a copy of the unique name from record 0x1006, insert the nested type at
offset 4, set offset 3 to actual[3], and compare the strings.
5) If they're the same, We create a definition of U::V<int> inside of U,
otherwise it's an alias (e.g. template<typename T> using V<T> = {0x1004});
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20181109/c553452f/attachment.html>
More information about the llvm-bugs
mailing list