[llvm-dev] StructType --> DICompositeType?
via llvm-dev
llvm-dev at lists.llvm.org
Tue Jul 24 10:54:57 PDT 2018
They aren't directly tied together, as a type by its lonesome isn't all that interesting to either compilers or debuggers.
But for example a global variable has a link to its DIGlobalVariable, which has a link to its DIType, and so you can associate the variable's Type with a DIType that way.
--paulr
From: llvm-dev [mailto:llvm-dev-bounces at lists.llvm.org] On Behalf Of Troy Johnson via llvm-dev
Sent: Tuesday, July 24, 2018 11:50 AM
To: llvm-dev at lists.llvm.org
Subject: [llvm-dev] StructType --> DICompositeType?
Is there a more convenient way to obtain a DIType given a Type than matching up the strings for the names?
For example, given:
struct S {
int x, y;
} s;
void foo(S *a) {
a->x = 0;
a->y = 1;
}
There are DIType nodes for the struct Type:
!6 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "S", file: !3, line: 1, size: 64, flags: DIFlagTypePassByValue, elements: !7, identifier: "_ZTS1S")
!7 = !{!8, !10}
!8 = !DIDerivedType(tag: DW_TAG_member, name: "x", scope: !6, file: !3, line: 2, baseType: !9, size: 32)
!9 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
!10 = !DIDerivedType(tag: DW_TAG_member, name: "y", scope: !6, file: !3, line: 2, baseType: !9, size: 32, offset: 32)
but given just the StructType for S there is no direct way to get to the DICompositeType. I've made something work by prescanning all the DITypes in my Module and creating a map that uses type names as the key, being careful to strip "struct." prefixes and maintain scoping for nested structs (e.g., S1::S2), which works, but seems awfully complicated to need to do.
Seems like StructType should have a getMetaData() function, but I don't see one.
-Troy
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20180724/5e7731ab/attachment.html>
More information about the llvm-dev
mailing list